Difference between revisions of "PHP"

From CSEE Documentation
(imported PHP guide to wiki format, fixed some instructional errors)
 
(added regular non-CGI instructions)
Line 1: Line 1:
==Using PHP on CSEE Personal Web Pages==
+
==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)
 +
# Insert PHP statements anywhere in your file. Start each block of statements with <code><?php</code> and end it with <code>?></code> For example, to print a simple "Hello world!":<br/><code><nowiki><?php echo '<p>Hello world!</p>'; ?></nowiki></code>
 +
# Make sure you set permissions properly on your script:<br/><code>chmod 755 ~username/www/filename.php</code>
 +
# Load the page with your favorite Web Browser to ensure that it works.
  
1. Using PHP on CSEE web servers is the same as using any other CGI langauge such as Perl. Review the instructions at the [[CGI|CSEE CGI Guide]] to become familiar with using CGI.
+
==Using PHP in CGI scripts==
  
2. Create your PHP file (make sure it has a .php extension), e.g. ~username/www/filename.php
+
# Using PHP on CSEE web servers is the same as using any other CGI langauge such as Perl. Review the instructions at the [[CGI|CSEE CGI Guide]] to become familiar with using CGI.
 +
# Create your PHP file (make sure it has a .cgi extension), e.g. ~username/www/filename.cgi)
 +
# The first line of that file should read:<br/><code>#!/usr/site/bin/php</code>
 +
# Write your PHP script. See the example above.
 +
# Make sure you set permissions properly on your script:<br/><code>chmod 755 ~username/www/filename.cgi</code>
 +
# Load the page with your favorite Web Browser to ensure that it works.
  
3. The first line of that file should read:
+
==Documentation==
 
+
*[http://us2.php.net/manual/en/tutorial.php PHP Simple Tutorial]
<code>#!/usr/site/bin/php</code>
+
*[http://us2.php.net/manual/en/index.php PHP Manual]
 
 
4. Write your PHP script. Documentation describing the PHP langauge can be found at http://www.php.net.
 
 
 
5. Make sure you set permissions properly on your script:
 
 
 
<code>chmod 755 ~username/www/filename.php</code>
 
 
 
6. Load the page with your favorite Web Browser to ensure that it works.
 

Revision as of 18:14, 9 January 2007

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 755 ~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/site/bin/php
  4. Write your PHP script. See the example above.
  5. Make sure you set permissions properly on your script:
    chmod 755 ~username/www/filename.cgi
  6. Load the page with your favorite Web Browser to ensure that it works.

Documentation