|
Next step is explaning how to install PHP, MySQL, or Apache Server. If your server supports PHP - you don't need to do anything! You do not need to compile anything or install any extra tools - just create some .php files in your web directory - and the server will parse them for you. Most web hosts offer PHP support. However, if your server does not support PHP, you must install PHP. Below is a link to a good tutorial from PHP.net on how to install PHP5: http://www.php.net/manual/en/install.php Download PHP for free here: http://www.php.net/downloads.php Download MySQL for free here: http://www.mysql.com/downloads/index.html Download Apache for free here: http://httpd.apache.org/download.cgi Writing PHP on your computer is actually very simple. You don't need any specail software, except for a text editor (like Notepad in Windows). Run this and you are ready to write your first PHP script. Declaring PHP PHP scripts are always enclosed in between two PHP tags. This tells your server to parse the information between them as PHP. The three different forms are as follows: <? PHP Code In Here ?> <?php PHP Code In Here php?> <script language="php"> PHP Code In Here </script> All of these work in exactly the same way but in this tutorial I will be using the first option (<? and ?>). There is no particular reason for this, though, and you can use either of the options. You must remember, though, to start and end your code with the same tag (you can't start with <? and end with </script> for example). The first PHP script you will be writing is very basic. All it will do is print out all the information about PHP on your server. Type the following code into your text editor: <? phpinfo(); ?> As you can see this actually just one line of code. It is a standard PHP function called phpinfo which will tell the server to print out a standard table of information giving you information on the setup of the server. One other thing you should notice in this example is th at the line ends in a semicolon. This is very important. As with many other scripting and programming languages nearly all lines are ended with a semicolon and if you miss it out you will get an error. Finishing and Testing Your Script Now you have finished your script save it as phpinfo.php and upload it to your server in the normal way. Now, using your browser, go the the URL of the script. If it has worked (and if PHP is installed on your server) you should get a huge page full of the information about PHP on your server. If your script doesn't work and a blank page displays, you have either mistyped your code or your server does not support this function (although I have not yet found a server that does not). If, instead of a page being displayed, you are prompted to download the file, PHP is not installed on your server and you should either serach for a new web host or ask your current host to install PHP. It is a good idea to keep this script for future reference.
Credits: www.freewebmasterhelp.com, www.w3schools.com
|