ITEC 325 - PHP (PHP Third Edition by Ullman)
Chapter 1 Lecture Notes
Based on notes by Jack Davis (jcdavis@radford.edu)
- The obligatory "hello world" example.
https://php.radford.edu/~ibarland/ITEC325/2011spring-ibarland/Lectures/php/hello-world.php
- Standard XHTML
- all tags lowercase
- nested tags must be well formed
- all tag attributes must be quoted
- all tags must be closed (even standalone tags) <hr>
- Strong convention:
Must use CSS for all formatting
- PHP Interpreter, Copy and Execute Modes
- Executing PHP at RU
- dynamic_php
- directory permissions set to 711
- file permissions set to 700
-
PHP Info. at RU
- Debugging PHP Scripts
- You can only run scripts on a PHP enabled Web Server
- Here at RU, the error log is not accessible to individual users
- We can pipe error messages through to the browser, however, this is
only true if it's not a fatal error.
If the error causes the
script to end, control reverts to the Apache process that is running
the script, which can not output to the client browser.
To overcome
this issue the client can include the new PHP file in another PHP file.
Then when an error is generated, the PHP include file receives control and
can send the generated error message to the client.
- Here is an
example php file with a fatal error.
Note what is returned to the client.
file-with-error.php
Here is a second file which simply turns on errors,
and then includes the original php file (file-with-error.php)
file-with-error-via-include.php
-
If you have access to server configuration-files,
you could just turn those error settings on by default, instead of having the program itself do so.
However, for production machines, you don't want to send raw error messages to the user;
the default approach is to ... send a different raw error message, http '500' result.
- PHP Manual
- Comments (//, /*, #)