Debug Your Code
Debug Your Code
Please remember, users are entirely responsible for their code.
The URLs:
http://afsaccessX.njit.edu/~UCID/... (where X = 1,2,3,4) |
can be used as an aid to debug your code. The Apache webserver log files access_log and error_log that correspond to the above URLs are located in /export/apache/logs on afsaccess1.njit.edu - afsaccess4.njit.edu. You can examine these log files to debug your code.
Before accessing any of the URLs above, run :
homepage.debug.setup |
The Apache-PHP running on the afsaccessX listed above is the same as that running on web.njit.edu. The URLs listed above are accessible only from within the NJIT network - i.e., from on the NJIT campus, or via VPN.
Note: For security reasons, errors that occur during the execution of PHP code are not displayed as a part of the output. As a workaround, see Alternate Method below.
Example of Using Log Files
Assume that your UCID is "abc123", your program is titled "homework4.php", and you use afsaccess3.njit.edu to debug it.
- When you log in, the file is "public_html/homework4.php", or extended "/osl/cad/a/b/abc123/public_html/homework4.php".
- The URL will be "http:/afsaccess3.njit.edu/~abc123/homework4.php"
- You could find error messages on afsaccess3.njit.edu with these commands:
cd /export/apache/logs grep abc123/public_html/homework4.php access_log error_log - The last message displayed would be from your last attempt to use the script.
Some types of syntax errors can be easily found by running a test of your PHP script from the system command line with the "php" (/usr/local/bin/php) command. For the example given above, the command would be:
cd $HOME/public_html php homework4.php This would display the same error message as shown in the example. However, if your script has no errors, all the HTML generated by the script will be displayed on your screen, and you might be prompted for input variables. Press CTRL-C to exit "php", and use the first technique for additional debugging.