Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg

PHP : Appendices : Debugging PHP

Appendix G. Debugging PHP

About the debugger

PHP 3 includes support for a network-based debugger.

PHP 4 does not have an internal debugging facility. You can use one of the external debuggers though. The » Zend IDE includes a debugger, and there are also some free debugger extensions like DBG at », the » Advanced PHP Debugger (APD) or » Xdebug which even has a compatible debugger interface as PHP 3's debugging functionality as is described in this section.

Code Examples / Notes » debugger


[Ed: Note: Python loop control is managed through indentation, so you will need to reindent this errata note]
python remote debug listener...
#Used for remote debugging of PHP programs.
from socket import *;
#connect and bind to the port
s = socket(AF_INET, SOCK_STREAM);
#little info to print out
print "PHP Remote Debug Application";
#let us try this thing...
while 1:
client, addr = s.accept();
tmp = client.recv(1024);
while tmp:
print tmp, "\n";
tmp = client.recv(1024);
print "Exit";


want a simple way to get errors from php?
from the command line simply type:
"/path-to-php/php.exe your-php-file.php3"
and It'll throw back useful errors
use -q option before the filename to Suppress HTTP Header output.


Tired of manualy printing out your variables and arrays for debugging?
Take a look at my debuglib at:
Happy debugging!
Thomas Schüßler


There is actually a symbolic debugger for php4 : BIKE.
It only works on unix/linux, and is a bit limited, but it's better than the existing (rather limited) system and typing tons of echos.
See it at :

14-sep-2006 04:51

NuSphere Php IDE PhpED ( includes dbg from actually


Meanwhile, a Windows binary is available too:


I've tried many debuggers and PHP IDEs including Zend IDE, Komodo, PHPEdit, PHPEd and Maguma Studio.
After all I'm sure that the best one debugger is dbg. It supports breakpoints even conditional ones,  all kind of steps throu php code, watch etc, so it's a fully functional debugger indeed and profiler too. Fortunately, it's an open-source product as PHP itself. Unfortunately, it does not contain any front-end, but 3rd party PHP IDEs. Seems, as for an IDE the best one is PHPEd 3.1 (, former PHP IDE from Ergin Soysal.
I was also deeply impressed with IonCube accelerator performance ( Commercial version of IONCUBE is many times faster than the commercial one from Zend ( Huh ?
Hope this info would help someone to find the better way faster.


I've started creating an external debug server for PHP. A PHP app require_once's a TADebugger(), which communicates with the debug sever. Find the OS X universal binary here [PHP source sample included]:
Currently, TADebugger allows to post these properties back to the debug server:
- Call backtraces
- String messages
- Source files, which were referenced by a backtrace call
Note, that the binary is a early version.


I'm copying this note from a post I found on Geocrawler.  I think Thierry diserves a round of applause for actually posting something useful, so...
I'm going to add some syntax highlighting to the code to make it cute, and then we'll see.
FROM: Thierry Boudet
             DATE: 12/01/1998 01:35:21
             SUBJECT: RE:  [PHP3] [php3] get the debug info
             Rui Barreiros a écrit:
             > how can i get the debug info that the php3 sends to port 2000 (in my
             > case)
             #!/usr/bin/perl -w
             use Socket;
             $port = 7869;           # PHP debugger
             my $proto = getprotobyname('tcp');
             socket(Server, PF_INET, SOCK_STREAM, $proto)
                                        or die "socket: $!";
             setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l",1))
                                        or die "setsockopt: $!";
             bind(Server, sockaddr_in($port, INADDR_ANY))
                                        or die "bind: $!";
             listen(Server, SOMAXCONN);
             for ( ; $paddr = accept(Client, Server); close Client)
                 my ($port, $iaddr) = sockaddr_in($paddr);
                 my $name = gethostbyaddr($iaddr, AF_INET);
                 print "-------------  $name  $port --------";
                 while (<Client>)        {  print;   }

online _ use _ only ==

I still find that printing out variable values at problem points in the code is one of the easiest ways for me to debug.  If you're interested in knowing the full contents of an object/array/scalar, then use




$debugger=new blackbox();



 echo "<pre>";


23-aug-2002 07:51

check out this great, cross-platform, my favourite php debugger:
it not only allows "debugging PHP programs locally or remotely, including debugging in CGI or other Web Server API environments", but, besides, is a full fledged Perl, PHP, Python, Tcl, and XSLT IDE. based on mozilla.
current version 1.2.9 costs some money ($29.50 non commercial), previous version 1.1 is free (non commercial).


Both php3 and php4 ( dbg extention ) are supported by Quanta Plus ( )
It's a full featured IDE for Unix ( KDE )
which supprt PHP too.


Another free (GPL) debugger is Gubed, .
Currently available for Linux, but also Windows soon.

Change Language

Follow Navioo On Twitter
History of PHP and related projects
Migrating from PHP 5.1.x to PHP 5.2.x
Migrating from PHP 5.0.x to PHP 5.1.x
Migrating from PHP 4 to PHP 5
Migrating from PHP 3 to PHP 4
Migrating from PHP/FI 2 to PHP 3
Debugging PHP
Configure options
php.ini directives
List of Supported Timezones
Extension Categorization
List of Function Aliases
List of Reserved Words
List of Resource Types
List of Supported Protocols/Wrappers
List of Available Filters
List of Supported Socket Transports
PHP type comparison tables
List of Parser Tokens
Userland Naming Guide
eXTReMe Tracker