Trace statements for PHP

If you're a Flash developer then you probably use trace() as an essential part of your development routine. Maybe you even wrote a custom logger application to get a peak into what's happening with your Flash application. Point is that you like to see what's going on behind the scenes.

Now you've moved on to the big leagues and started connecting Flash to PHP to add server-side functionality to your application, but how do you see what's happening with your PHP code? PHP has a little know feature called error_log() that lets you output messages to your web server's log file. By tailing your log files while running your application you essentially get trace statements from your PHP code! You can do this by opening your terminal if on a Mac or use something like cygwin on Windows, change directories to where the log files are and run the tail command with the follow flag.
Welcome to Darwin!
colossus:~ chris$ cd /var/log/httpd/
colossus:/var/log/httpd chris$ tail -f error_log
[Tue Jun  5 22:31:11 2007] [error] This is my trace statement from PHP!
Enjoy and happy PHP testing!

Comments are closed.