Home || Syllabus || Readings || Assignments || Resources


Introduction to PHP: -- for class discussion

For example:

Using the following code:

<?php include('DT_menuText_fa13.html'); ?>

...and this text file (see DT_ menuText_fa13.html)

... the menu appears above consistently on all of the webpages in this site. Therefore, in order to change the menu throughout the site, one would only need to make the change in one place.


Steps

  1. Prepare the content that would be used in multiple pages (e.g. code in the header to call a favicon and .css; code for a menu or a footer or other content that you would like to use in multiple files.)
  2. Use <?php include("filename.html"); ?> with the appropriate file name to include in the web page code view
  3. Be sure that your webpage has a suffix of .php and not .htm or .html
  4. Note that .php files should have permissions to be "world-executable" (755) and the .html or .txt file should have permissions of 644 like your other webpages and images.
  5. Be sure to post your PHP files to your i6.cims.nyu.edu for testing as you will not be able to test them locally.
  6. NOTE: PHP is called a "server-side" language ... as it runs on the server. JavaScript however is a "client-side" language as it runs in the browser or "locally".