PHP - Scripting the easy way
PHP is an open source, cross platform scripting language that takes the best of Perl, Java, JavaScript and other languages. The language is designed explicitly for building web sites. PHP includes built in database connectivity as well as a variety of string manipulation functions and much more. PHP is designed to output HTML pages for use in browsers. Since it is server-side processing there is less browser dependency issues. Output good proper HTML and you will have fewer user (client browser) errors.
To learn more about PHP keep reading and go to:
Path to PHP on the YouGoWeb servers:
#!/usr/bin/phpPHP can be included in HTML documents, or entire files can be written in PHP. PHP allows for the same thing to be done in a number of ways which is good but understand that this tutorial is only a could examples. PHP is flexible to allow for you to do things may ways and they can all be correct. For example, both of these examples produce the same web page:
1) Example HTML with PHP embedded - Click here to test this script.
PHP code in blue2) You can
see all of the information about the php system and the paths by
creating the
following php test program. -
Click here to test this script.
Use lots of Comments (#) to explain what you are doing for others who use your code as well as remind you of what you were doing with this code, well after you have forgotten.
You can
make the code that the PHP outputs more readable to aid in fixing
any errors (tech speak would say "debugging") by putting
text line breaks in your code ("\n") where you would
naturally have a return. For example:
Regular HTML
<p>This is line 1<br>
This is line 2</p>
PHP
print "<p>This is line 1<br>\n";
print "This is line 2</p>\n";
Clean, easy to read code will make your life easier and lead to higher quality projects.
Now that we have a simple PHP page working let's dicuss passsing variables in to HTML documents output by PHP scripts and databases from a web form.