Difference between revisions of "PHP"

From CSEE Documentation
Line 1: Line 1:
 +
Set up your [[Web Introduction|Personal Web Site]] if you have not done so already.
 +
 
==Using PHP in HTML documents (recommended)==
 
==Using PHP in HTML documents (recommended)==
 
# Create a PHP-enabled HTML file (make sure it has a .php extension), e.g. ~username/www/filename.php)
 
# Create a PHP-enabled HTML file (make sure it has a .php extension), e.g. ~username/www/filename.php)

Revision as of 16:11, 6 August 2019

Set up your Personal Web Site if you have not done so already.

Using PHP in HTML documents (recommended)

  1. Create a PHP-enabled HTML file (make sure it has a .php extension), e.g. ~username/www/filename.php)
  2. Insert PHP statements anywhere in your file. Start each block of statements with <?php and end it with ?> For example, to print a simple "Hello world!":
    <?php echo '<p>Hello world!</p>'; ?>
  3. Make sure you set permissions properly on your script:
    chmod 705 ~username/www/filename.php
  4. Load the page with your favorite Web Browser to ensure that it works.

Using PHP in CGI scripts

  1. Using PHP on CSEE web servers is the same as using any other CGI langauge such as Perl. Review the instructions at the CSEE CGI Guide to become familiar with using CGI.
  2. Create your PHP file (make sure it has a .cgi extension), e.g. ~username/www/filename.cgi)
  3. The first line of that file should read:
    #!/usr/bin/php
  4. Write your PHP script. See the example above.
  5. Make sure you set permissions properly on your script:
    chmod 705 ~username/www/filename.cgi
  6. Load the page with your favorite Web Browser to ensure that it works.

Documentation