|
[php home] PHP Intro PHP originally stood for "Personal Home Page" when it first appeared in 1994. Today, the letters generally are understood to mean "Hypertext Preprocessor." PHP is an imbedded scripting language which means that the PHP code is placed inside regular HTML pages. Code that is placed within the <?php .... ?> tags will be processed by the web server before it is sent to the web browser. Pages that contain PHP code will use a ".php" extension rather than the usual ".htm" or ".html" extension. PHP Code Basics: PHP code is placed between the <BODY> </BODY> tags in your
HTML document. There are several opening and closing PHP tags that are
used. The two most common are: ?> and <? ?> Of these two, the first set (formal PHP) is generally recommended. PHP must be enabled on the web server. Today, many ISPs support PHP scripting. To see if PHP is active, our first PHP page will be a test to verify that PHP is enabled on the server. create a new text document with the following tags: <html> <?php phpinfo(); ?> </body> NOTE: all statements (a line of executable code) must end with a semicolon save the document as "php_1.php" and ftp it to your web folder and open When the page is opened, you should see several pages of PHP related information about the PHP settings on your server. Displaying PHP in your web browser: There are several ways to display PHP information on your page. The most frequently used tags are echo() and print(). Remove the phpinfo(); tag and add these tags to your page. <?php View the source of your new page. Note that none of the PHP code is returned. NOTE: Multiple chunks separated with a comma can be used with echo() but not print() Formatting output using HTML You can place regular HTML tags inside PHP tags to change output. Make the following changes to your text. <?php NOTE: when adding html code, omit the quotes or escape them by using a "\" - <font size=\"+2\"> Adding Comments: Like HTML, you should add comment tags to your work when using PHP. PHP comment tags work pretty much the same way as they do in HTML; <!-- HTML comment goes here -- > There are three types of PHP comment tags. The first two are one line only. 1. # comment goes here Open your php_1.php page and add three comments using each of the above styles. Create comment lines which tell who designed the page, the date it was designed and a couple of sentences about the designer. Remember, because the comment tags are inside your <?php ... ?> tags, you will not see them when you view the page source. |