[PHP] Debuggin PHP
Hello I'm a newbie in php world , and I'm trying to get a php 4 script work on an php5 version how do i debug php ? I get a blank page and nothing tells me what 's wrong ? Thanks hicham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
hicham wrote: Hello I'm a newbie in php world , and I'm trying to get a php 4 script work on an php5 version how do i debug php ? I get a blank page and nothing tells me what 's wrong ? Thanks hicham Turn on error reporting. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
hicham wrote: Hello I'm a newbie in php world , and I'm trying to get a php 4 script work on an php5 version how do i debug php ? I get a blank page and nothing tells me what 's wrong ? the hard way: install and use Xdebug. easy way 1: buy a copy of Zend Studio, again install on the server part on your server (which is automated if your development machine is your local machine) - much simpler to setup than Xdebug and very easy to use. easy way 2: use lots of echo()/var_dump()/print_r() in your code to figure out where it's breaking. NB: turn on error_reporting to full: ini_set('error_reporting', E_ALL | E_STRICT); NB: turn on diplay_errors (or find your php or apache log, it depends, and learn how to 'tail' it to what what if any errors are occuring) ini_set('diplay_errors', 1); Thanks hicham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
2006/4/26, John Nichel [EMAIL PROTECTED]: hicham wrote: Hello I'm a newbie in php world , and I'm trying to get a php 4 script work on an php5 version how do i debug php ? I get a blank page and nothing tells me what 's wrong ? Thanks hicham Turn on error reporting. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] error_reporting(E_ALL); at the beggining of your script or modify your php.ini
Re: [PHP] Debuggin PHP
On Wed, 2006-04-26 at 12:44, Jochem Maas wrote: hicham wrote: easy way 2: use lots of echo()/var_dump()/print_r() in your code to figure out where it's breaking. If you're trying to track down an error using this technique (by far one of the most popular techniques and time tested), be sure and use your knowledge of binary search algorithms to speed up your search. Applying the heuristic of guessing approximately where it's occurring will help you greatly also :) This kind of technique though is mostly only necessary when PHP does something stupid like segfault *grin*. Another fantastic technique is if you know the error occurs at a specific location, but don't know how the heck the script got there... you can use debug_backtrace(). Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
Robert Cummings wrote: On Wed, 2006-04-26 at 12:44, Jochem Maas wrote: hicham wrote: easy way 2: use lots of echo()/var_dump()/print_r() in your code to figure out where it's breaking. If you're trying to track down an error using this technique (by far one of the most popular techniques and time tested), be sure and use your knowledge of binary search algorithms to speed up your search. Applying the heuristic of guessing approximately where it's occurring will help that'll be the old 'put the first debug echo in the middle of the script technique :-) you greatly also :) This kind of technique though is mostly only necessary when PHP does something stupid like segfault *grin*. Another fantastic technique is if you know the error occurs at a specific location, but don't know how the heck the script got there... you can use debug_backtrace(). very good tips! Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
On 4/26/06, hicham [EMAIL PROTECTED] wrote: Hello I'm a newbie in php world , and I'm trying to get a php 4 script work on an php5 version how do i debug php ? I get a blank page and nothing tells me what 's wrong ? Thanks hicham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php (Assuming you're on *nix) One thing I always do when I'm developing is to locate the error log that PHP writes to. You can find it by looking at error_log in php.ini or find where Apache writes errors to. Then I just tail -f that so that I can see any errors including parse errors that just give you that no-ouput white screen. As others have mentioned always keep error_reporting to E_ALL.
Re: [PHP] Debuggin PHP
Robert Cummings wrote: On Wed, 2006-04-26 at 12:44, Jochem Maas wrote: hicham wrote: easy way 2: use lots of echo()/var_dump()/print_r() in your code to figure out where it's breaking. If you're trying to track down an error using this technique (by far one of the most popular techniques and time tested), be sure and use your knowledge of binary search algorithms to speed up your search. Applying the heuristic of guessing approximately where it's occurring will help you greatly also :) This kind of technique though is mostly only necessary when PHP does something stupid like segfault *grin*. Most of the times it is true, however, sometimes everything just fails. Apache continues to give segfaults on running a specific PHP script, which do don't find until you look into error logs of apache. Then you try to generate backtrace using gdb. All this while, on every try Apache+PHP keeps crashing on you. gdb backtrace too does not help much. So finally you compile bare bones apache+php and Voila! Everything works just fine.. From there, you go on adding one module per compilation to find the defaulter module and run /that/ PHP script after every compile to see if it crashes. And after a few compiles you find an Apache module to be a real culprit. -- Sameer N. Ingole Blog: http://weblogic.noroot.org/ --- Better to light one candle than to curse the darkness. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
On Wed, 2006-04-26 at 14:51, Sameer N Ingole wrote: Robert Cummings wrote: On Wed, 2006-04-26 at 12:44, Jochem Maas wrote: hicham wrote: easy way 2: use lots of echo()/var_dump()/print_r() in your code to figure out where it's breaking. If you're trying to track down an error using this technique (by far one of the most popular techniques and time tested), be sure and use your knowledge of binary search algorithms to speed up your search. Applying the heuristic of guessing approximately where it's occurring will help you greatly also :) This kind of technique though is mostly only necessary when PHP does something stupid like segfault *grin*. Most of the times it is true, however, sometimes everything just fails. Apache continues to give segfaults on running a specific PHP script, which do don't find until you look into error logs of apache. Then you try to generate backtrace using gdb. All this while, on every try Apache+PHP keeps crashing on you. gdb backtrace too does not help much. So finally you compile bare bones apache+php and Voila! Everything works just fine.. From there, you go on adding one module per compilation to find the defaulter module and run /that/ PHP script after every compile to see if it crashes. And after a few compiles you find an Apache module to be a real culprit. I use binary search for module seg faults also when the module is unknown :) Also for segfaults, the error log (or just plain run from CGI) can be handy to see your output before the crash. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
On Wed, April 26, 2006 11:30 am, hicham wrote: I'm a newbie in php world , and I'm trying to get a php 4 script work on an php5 version how do i debug php ? I get a blank page and nothing tells me what 's wrong ? Check View Source in your browser to see if it's really blank. Make sure PHP is installed and functioning with ?php phpinfo();? Check your php.ini settings and see if errors are displayed, logged, or discarded, and what your error_reporting is set to. Also check the script itself to see if it resets error_reporting -- which, if it does, is a clear indicator that the author of the script didn't know what they were doing and you shouldn't use their script anyway. You can also use Firefox and its extension to see HTTP Headers to see what headers, if any, come out of the server. You can also run PHP from the command line to see what the script outputs in that environment, which is sometimes useful, and sometimes too different from web environment to be useful. Just depends. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php