Toolserver:PHP

Background scripts & scheduling
PHP scripts can be left running on the server using a screen session or scheduled to run at set times using cron. PHP scripts run this way cannot use $_POST or $_GET variables.

Errors on page
You can configure PHP to output descriptive error messages by adding these lines to the top of the PHP file: error_reporting(E_ALL); ini_set('display_errors', 1);

Syntax errors
If the page fails to load (error 500), you can check for syntax errors from the command line: $ php -l myscript.php

On the toolserver, this will append errors to the user log. You can tail the file to see your syntax errors: $ tail -f /var/log/userlog | grep myscript.php

Segmentation fault
To debug a PHP script which crashes with a segmentation fault, type: $ gdb php-cgi $ run myscript.php

Then wait for your script to run. When it crashes, type: $ bt

flush does not work!
flush does not work. To be precise: flush does work but a layer of buffering outside the PHP interpreter makes it appear to not work. Circumvention: send a lot of whitespace characters after the output that you want flushed - a total length of useful_text + whitespace greater than 8192 bytes should be sufficient. (Clearly, sending whitespace is a waste of bandwidth so this trick should be used sparingly.)