Difference between revisions of "PHP"
From CSEE Documentation
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | ==CSEE Personal Web Site== |
Set up your [[Web Introduction|Personal Web Site]] if you have not done so already. | 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. | + | # Create a PHP-enabled HTML file (make sure it has a .php extension), e.g. /web/userpages/''username''/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> | # 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 705 | + | # Make sure you set permissions properly on your script:<br/><code>chmod 705 /web/userpages/''username''/filename.php</code> |
# Load the page with your favorite Web Browser to ensure that it works. | # Load the page with your favorite Web Browser to ensure that it works. | ||
Line 11: | Line 11: | ||
# 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 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. | + | # Create your PHP file (make sure it has a .cgi extension), e.g. /web/userpages/''username''/filename.cgi) |
# The first line of that file should read:<br/><code>#!/usr/bin/php</code> | # The first line of that file should read:<br/><code>#!/usr/bin/php</code> | ||
# Write your PHP script. See the example above. | # Write your PHP script. See the example above. | ||
− | # Make sure you set permissions properly on your script:<br/><code>chmod 705 | + | # Make sure you set permissions properly on your script:<br/><code>chmod 705 /web/userpages/''username''/filename.cgi</code> |
# Load the page with your favorite Web Browser to ensure that it works. | # Load the page with your favorite Web Browser to ensure that it works. | ||
Latest revision as of 14:19, 23 July 2024
CSEE Personal Web Site
Set up your Personal Web Site if you have not done so already.
Using PHP in HTML documents (recommended)
- Create a PHP-enabled HTML file (make sure it has a .php extension), e.g. /web/userpages/username/filename.php)
- 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>'; ?>
- Make sure you set permissions properly on your script:
chmod 705 /web/userpages/username/filename.php
- Load the page with your favorite Web Browser to ensure that it works.
Using PHP in CGI scripts
- 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.
- Create your PHP file (make sure it has a .cgi extension), e.g. /web/userpages/username/filename.cgi)
- The first line of that file should read:
#!/usr/bin/php
- Write your PHP script. See the example above.
- Make sure you set permissions properly on your script:
chmod 705 /web/userpages/username/filename.cgi
- Load the page with your favorite Web Browser to ensure that it works.