Quick Table of Contents
[Edit] Brief introduction
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Example</title> </head> <body> <p> <?php $name = "Mac"; $birth_year = 1992; $age = date( "Y" ) - $birth_year; echo "Hi My name is $name and my age is $age"; ?> </p> </body> </html>
[Edit] The Development Environment
Since PHP is executed on the server, we’ll need one. The best way to develop PHP applications is offline using a server package installed on your computer. Alternatively, you could use a private server.
If you prefer developing on a live web server by FTP’ing your files every time you make changes — although not advisable — I can’t stop you.
But now, we’ll do it right and install a server package on our computers: XAMPP
[Edit] Installing XAMPP
It’s possible to download Apache (the name of the web server software) and PHP individually and then set it up manually. However, its way easier to use XAMPP, a bundled package containing the software we’ll need.
To install XAMPP, we obviously need to download it first. Go to the XAMPP website, select your operating system and start downloading the basic package. XAMPP is cross-platform, so it’s available for the Mac OS, Windows, and Linux.
When your download is finished, open it.
An installation wizard will pop up when you run the executable file. You only have to specify a path (Do not install it in c) and you are good to go. Because a lot of files are being copied, this might take a while.
When it’s done copying files, a command screen will appear. It’ll ask you a few questions but most of them are just personal preferences. If you have no idea which option you should choose, just accept the default settings.
After a few questions, it’s done configuring and you’ll be asked what you want to do next.
Let’s disable HTTPS, Perl, and ASP. We are disabling them because we won’t need them. If you do want to use these later on (HTTPS is especially nice if you are developing a financial app or something that needs a secure transfer protocol), you can enable them at that point in time.
When the installation is complete, open the XAMPP Control Panel.
This is what your XAMPP Control Panel should look like.
On the XAMPP Control Panel, click the first Start button to start the Apache software. If you don’t want to open the control panel every time you want to start Apache, press the first SVC button. Press the Exit button to close the Control Panel.
Congratulations, your web server is ready for use! Point your web browser to http://localhost, take a deep breath and keep your fingers crossed.
[Edit] Choosing a Code EditorEditor
Writing PHP code in your regular word-processing editor like Microsoft Word is not an option. It’ll add all sorts of junk (e.g. style definitions, proprietary characters, etc.) to your document — and PHP isn’t able to process that junk.
You’ll need a text editor to writing, editing and debugging PHP such as:This full list
Syntax Highlighting is ImportantSo you open Notepad and you’re ready to start writing a few lines of code. It’s time to test what you’ve written and PHP tells you that you forgot a single quote on line X, and it is therefore unable to run your script. If you are working with "a few lines of code," it won’t be hard to determine where you forgot the single quote.
But what if there are a "few thousand lines of code"?
Meet syntax highlighting. When enabled, instructions, declarations and so forth will have their own color (it’s not added to the document, so no junk!). Even without knowing what the following piece of code does, it will only take a second to find the missing single quote.
Finding the missing single quote is a piece of cake with syntax highlighting enabled.
|awesome way to move a tree and keep its life||DIY | 3 Amazing Diet Coke Can Hacks||Animation Shows 550 Million Years Of Human Evolution In Seconds|
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
© Advanced Web Core. All rights reserved