Saturday, April 23, 2011

Creating and Viewing a PHP Page

The following are step-by-step instructions for creating your own PHP (PHP Hypertext Processor) applications on the Baruch linux lab server.
  1. Follow all of the instructions above on how to create a web (HTML) page.
    Make sure you have created your test HTML page and that it works.
  2. Change to the public_html directory using the cd command as follows:
    cd public_html
  3. Now you can create a new PHP page. For example, we will create a PHP page and name it:
    Use the pico editor to create this simple PHP page. Type: pico mypage.php and then when Pico starts up, type in the following HTML and PHP text:<xmp style="font-family: 'Times New Roman'; white-space: normal; "><xmp><HTML> <BODY> <H1>This is my first PHP Page</H1> <P> Here is some text in my new PHP page <P> <?php echo '<p>Hello World from PHP</p>'; ?> <P> <?php echo 'Today is: '; echo date("F d Y"); ?> <HR> <P> Bye for now </BODY> </HTML>Save this file and exit pico.
  4. Change the permissions of this file so others can read it:
    chmod 644 mypage.php
  5. To access this page while on Baruch's campus, the URL takes the form: 
  6. For example, if your username is billg and you made a page called mypage.html then your PHP URL is: 
  7. Note that you can also create subdirectories under your public_html directory for different projects and collections of pages.
Some PHP Tutorials can be found here:

No comments:

Post a Comment