Debugging php message window style

From Director Online Wiki
Jump to: navigation, search

Most php debugging can be done simply using browser. But there are times when this is awkward (i.e. when building custom http headers). Here's a way to 'put' data to a consol window while your php executes (requires a *nix environment):

SSH to your php directory and enter the following:

mkfifo -m 772 .debug
tail -f .debug

Now in your php scripts direct debug messages to the debug FIFO with:

exec("echo \"Some debug statement or $var\" > .debug");

or use a text file for output:

exec("echo \"Some debug statement or $var\" >> debug.txt");

When the php executes, you can watch the output in your SSH session. (NOTE: Make sure you're tailing your fifo when the php runs otherwise it'll hang while php waits for you to read the output or just use a text file as mentioned.)

--[[User:Cole|CBT]] 13:17, 12 Oct 2005 (MDT)