473,831 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debugging PHP

Hi All,
I've just started writing PHP scripts. I was wondering whether there was
any sensible debugging facilities that I'm not aware of. Basically, my usual
development procedure involves writing the script and then testing using IE.
However, it appears that unless the PHP is perfect (ie. devoid of any
syntactical errors) then nothing at all is output to the browser. Personally
I find this very frustrating as there's no clue as to where the error is. I
then commence on a wild goose chase putting in various debugging 'echo'
statements and commenting out various chunks of PHP code until something
works. There must be a better approach than this.

Are there any option or selections I can make to give me some debugging
output?. Is there a parser I can use to ensure there are no syntactical
errors before running the script?. Or a PHP debugger I can use to step
through the code command by command?.

Thanks,
Dave

Jul 17 '05 #1
12 1702
Dave Moore wrote:
Are there any option or selections I can make to give me some debugging
output?


Put this at the top of your PHP script:

error_reporting (E_ALL);

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #2
Dave,

Putting error_reporting (E_ALL) directly in your script may not be
necessary. By default, this value is already set in PHP. Use
phpinfo() to find out if it is.

Your best bet is to put in echo, print, or fwrite(for command line
interface) in your script at key points. This will help you "walk"
through it.

There are several IDE's that have debugging capabilities. They may
even be able to run the script or step through it.

There is a free IDE for PHP (http://syn.sourceforge.net/). It is a
decent editor with Syntax highlighting and the such. It also has
debugging capabilities. However, I never had luck getting this aspect
to work and gave up on it. But, it is a decent editor. I would not
that it seems to be a bit of a process and memory hog at random times.

Jul 17 '05 #3
Hi Dave,

The following is not a debugger, but it can be very helpfull nevertheless:
http://nl2.php.net/manual/en/functio...-backtrace.php
feed the array to print_r to see what exactly you get. Then it should
not be hard to build a fancy backtrace printing function.

If you make an error handling function and set its name with
set_error_handl er you can make it print a backtrace below the
coventional error info. (search the manual for set_error_handl er)

Limitation: it will not work for fatal errors - imho the person that
decided that php developers do not need error handling for fatal errors
made a fatal mistake :-(((

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

Dave Moore wrote:
Hi All,
I've just started writing PHP scripts. I was wondering whether there was
any sensible debugging facilities that I'm not aware of. Basically, my usual
development procedure involves writing the script and then testing using IE.
However, it appears that unless the PHP is perfect (ie. devoid of any
syntactical errors) then nothing at all is output to the browser. Personally
I find this very frustrating as there's no clue as to where the error is. I
then commence on a wild goose chase putting in various debugging 'echo'
statements and commenting out various chunks of PHP code until something
works. There must be a better approach than this.

Are there any option or selections I can make to give me some debugging
output?. Is there a parser I can use to ensure there are no syntactical
errors before running the script?. Or a PHP debugger I can use to step
through the code command by command?.

Thanks,
Dave

Jul 17 '05 #4
That won't help when there's a parse error. The solution here is to
make sure display_error is set to "on" in php.ini and error_reporting
to something sensible, like E_ALL & ~E_NOTICE.

Jul 17 '05 #5
On 30 Apr 2005 11:26:43 -0700, "Chung Leong <ch***********@ hotmail.com>"
<ch***********@ hotmail.com> wrote:
That won't help when there's a parse error. The solution here is to
make sure display_error is set to "on" in php.ini and error_reporting
to something sensible, like E_ALL & ~E_NOTICE.


E_ALL is sensible whilst developing; don't turn off E_NOTICE.

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #6
On Sat, 30 Apr 2005 20:05:37 +0100, Andy Hassall wrote:
to something sensible, like E_ALL & ~E_NOTICE.


E_ALL is sensible whilst developing; don't turn off E_NOTICE.


Maybe even turn om E_STRICT (not included in E_ALL):

error_reporting = E_ALL|E_STRICT
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #7
Zend Studio has an excellent debugger, check it out at:

www.zend.com

Xdebug is your other option, basically both "inject" themselves into
PHP and you (the programmer) can debug via their perspective clients
(which listen for their requests on specific ports on your machine,
different than MS Studio debuggers).

Jul 17 '05 #8
On 1 May 2005 01:27:21 -0700, jo*******@gmail .com wrote:
Zend Studio has an excellent debugger [...] Xdebug is your other option


How about phpeclipse, apparently it includes a debugger (from eclipse,
or php-specific?), do you have any experience with that?
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #9
People should use whatever settings that's helpful. Personally I
program with E_WARNING off too.

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3232
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs converted/developed with VB.NET. What I want from debugging is to be able to step into the methods in the DLLs called from ASP scripts using Visual Studio .NET. Background: For typical script debugging issues, you can read and follow the two documents on...
16
4231
by: Serdar Kalaycý | last post by:
Hi everybody, My problem seems a bit clichè but I could not work around. Well I read lots of MSDN papers and discussions, but my problem is a bit different from them. When I tried to run the project in debug mode (by hitting F5) it gives an error message "Error while trying to run project: Unable to start debugging on the web server.
2
1856
by: Andy Fish | last post by:
Hi, Using VS.NET 2003, when I use 'F5' to start debugging my web app, it obviously attaches the IDE to IIS for server debugging. However, it also seems to put IE into some kind of debugging mode (for javascript debugging) This causes IE to consume loads of CPU if the page is very large. Is there any way to have debugging of server side code but leave IE in "normal" mode?
2
3278
by: Alex Clark | last post by:
Hi All, My system: WinXP Pro, VS.NET 2003, SQL Server Personal Edition. I'm having problems with my old favourite demon, SQL Debugging from within VS.NET. I have to say I've found this particular feature to be one of the most useful and (sadly) unreliable/fragile features in VS.NET, it seems the slightest thing will break it.
5
2960
by: Velvet | last post by:
Can someone tell me to what process I need to attach to be able to step through my classic ASP code in VS.net 2003. I'm working on an XP box with IIS installed. I also have VS.net 2005 (The final, never installed beta) installed on this box if it makes a difference (I did not install VS Development Web Server as I'm already using the XP web server). I've seen that I need to attach to the native IIS engine, but I don't know what it's...
6
2513
by: KevinGPO | last post by:
I am currently developing a website in ASP (VBScript) using MS Visual C#.NET IDE. I just create a new "ASP.NET Web Application" and point to my local webserver (IIS) of my website address. Then I just go through each file/folder and right-click, selecting "Include in project". The IDE is nice in that it checks, verifies id tags, etc. What am wondering is whether it's possible to debug my ASP website using the MS Visual Studio.NET's...
5
7804
by: phnimx | last post by:
Hi , We have developed a number of plug-in .NET Library Components that we typically deploy with our various applications by installing them into the GAC. Each of the applications contains an app.config file referencing arbitrary versions of the plug-in components they wish to consume. Here's the problem: Assuming I have installed any one of our application software,
5
3457
by: =?Utf-8?B?Z2FkeWE=?= | last post by:
I can't get to debug on my local IIS using VStudio.net 2005 Prof. I can on the development server. I get the msg 'the server does not support debugging for asp.net...' I have done the following as in 'How to: Enable Debugging for ASP.NET Applications' Under Debuggers ASP.NET box is selected in web.config set compilation debug="true" in virtual directory:
2
20863
jwwicks
by: jwwicks | last post by:
C/C++ Programs and Debugging in Linux This tutorial will give you a basic idea how to debug a program in Linux using GDB. As you are aware Visual Studio doesn’t run on Linux so you have to use some of the tools provided on the command-line. If you hate the command line tools, get over it since you’re bound to be using them at some point in your career. All commands in Linux ARE case sensitive so capital letters are different from lowercase...
4
12699
by: =?Utf-8?B?TWlrZSBHYWxl?= | last post by:
VS 2008 initially didn't debug classic ASP. SP1 fixes this in some ways. You can debug if you select the debug option to "Start Without Debugging, then either attach the debugger manually or place a stop directive in the code which ends up doing the same thing. The problem with this is that you can't debug browser side Javascript in the same debug run. You get a "The breakpoint will not currently be hit. The document is not loaded." if...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10777
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10493
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10206
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7747
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3960
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.