PHP: Hypertext Preprocessor. PHP is a server side scripting language that is used in creating dynamic web pages. Often used with MySQL so that the PHP files can use the data stored in the databases. To create a PHP file you will need to save the file as a .PHP file then in the code start programming php with the tag: <?php and end with the tag ?> Everything inside those tags is read as php outside those tags the code is read as HTML.
For outputting onto a webpage using PHP there are 2 methods. First is a Echo statement.
That would output Hello World onto the page. Also there is a print function to output to the webpage.
This will also output Hello World to the webpage. There is debate over which should be used for output. Echo seems to be faster in very large programs that just simply output text. To use quotes within a quoted text to be outputted to the webpage you have to use a backslash:
Setting Variables you would have to start the variable name with a “$” then followed by a letter or an underscore. For example:
Arrays in php are similar to java but instead of using integers as the index you can also use strings as the key or index for the array. Example:
Operators in PHP are similar to java including: +, -, /, *, <, >, ==, and !=. But for comparing variables you have to do it a little differently. For example:
Working with SQL and connecting to databases in PHP you use
I can use PHP to select data from our databases and create these tables:
To insert rows into tables in PHP you would use:
You can read in files using:
But this will read the whole file and most likely hang up
To set a Cookie in PHP you would use
You can retrieve the cookie using
Then you can output the cookie with
You can easily send emails using PHP as well using