473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What is the best way to debug/test a PHP code ?

Please let me know how do we effectively and quickly test a php code ?

Nov 28 '06 #1
5 2125
su******@gmail.com wrote:
Please let me know how do we effectively and quickly test a php code ?
Short question.
Difficult to answer.

It completely depends on your requirements.
You can judge the code by:
- security (header/email-injection, sql-injection, loginlogic)
- functionality: Does the code produce what you want, also if you feed it
information designed to confuse it.
- Codingstyle: Can a PHP programmer easily read through the code? Does it
have some comments to explain what is going on? If you use a database, is
it designed neat and smart?
- stresstesting: Do you expect a lot a concurent hits, and is the setup on
your machine capable of handling that? (Of course it is up to you to set
the minimum)

etc.

So what is it you want?

I think it is safe to say you need an experienced PHP programmer to judge
any of the above (except the stresstesting maybe).

Regards,
Erwin Moller
Nov 28 '06 #2
Following on from Erwin Moller's message. . .
>su******@gmail.com wrote:
>Please let me know how do we effectively and quickly test a php code ?

Short question.
Difficult to answer.

It completely depends on your requirements.
You can judge the code by:
- security (header/email-injection, sql-injection, loginlogic)
- functionality: Does the code produce what you want, also if you feed it
information designed to confuse it.
- Codingstyle: Can a PHP programmer easily read through the code? Does it
have some comments to explain what is going on? If you use a database, is
it designed neat and smart?
- stresstesting: Do you expect a lot a concurent hits, and is the setup on
your machine capable of handling that? (Of course it is up to you to set
the minimum)

etc.

So what is it you want?

I think it is safe to say you need an experienced PHP programmer to judge
any of the above (except the stresstesting maybe).

Regards,
Erwin Moller
Yes. "debug" and "test" are entirely different things.

Debug : Getting rid of reported faults
Exercise : Run all bits of code and show it can be made to work
Test : Look for weaknesses.

If you're wondering how to find out what's going on inside your program
when you get a run-time problem then you might simply put in a
print_r(), or write a log of function calls, variable watches etc to
another file. [My PHP system is off-line at the minute or you could
have my debugging library]

FWIW the way to develop Exercise and Test is by making notes as you're
building the code: What could possibly go wrong?... Silly
arguments...flag this for future investigation to stop interrupting flow
of coding thought...is that a [D] for document a [E] for exercise or a
[T] for needs testing (or all of them). Then when you're setting out to
exercise you look for "[E] comments " in the code and build the
exercises accordingly. And so on.

PS Personally I don't care much for black box testing if the white box
(stupid name) has been done well.

--
PETER FOX Not the same since the deckchair business folded
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Nov 28 '06 #3
su******@gmail.com wrote:
Please let me know how do we effectively and quickly test a php code ?
There have been whole volumes written about testing code and code
quality. It's not at all a simple question. Larger programming
departments have entire groups of people dedicated to test and quality
control.

As a short answer, you test code with valid data to ensure it does what
you want. Then you test it with invalid data to ensure it properly
handles the bad input. And when you make changes, you repeat the
process to ensure you haven't regressed anything.

Test scripts help a lot. But to use them the code must be well
documented and its purpose clear.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 28 '06 #4
En las nuevas, el su******@gmail.com escribió:
Please let me know how do we effectively and quickly test a php code ?
Run it and see if it works.
Nov 29 '06 #5
Tom
This is more related to debugging, but one thing I found very helpful
was writing my own error-handler so that it provided a trace when an
error did occur. This page is helpful:

http://www.php.net/manual/en/functio...or-handler.php

Also, someone mentioned print_r(). I wrote my own function that
basically does this, except formats the output more nicely and provides
a function and file trace.

If your code is more object-oriented, then unit-testing would a good
term to research.

Tom

On Nov 28, 12:49 am, "sudee...@gmail.com" <sudee...@gmail.comwrote:
Please let me know how do we effectively and quickly test a php code ?
Nov 30 '06 #6

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

Similar topics

2
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is...
29
by: Tom_OM | last post by:
I have a web site in which I offer freeware programs. They're true freeware, not crippled versions attempting to get people to buy the full versions. The beginning of my user license agreement...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
10
by: linq936 | last post by:
Hi, I have many assert() call in my code, now I am considering to replace them with exception. The reason I want to do this change is that with the program going bigger and bigger, it is hard to...
1
by: wen | last post by:
i have written python extend module by c/c++, but i saw a module of a software(pyMOL, you can get it from http://pymol.sourceforge.net/) called _cmd.pyd instead of _cmd.dll. and it is written by...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
0
by: Ken Allen | last post by:
The MSDN documentation on remote debugging is a bit sparse, to say the least, and there is almost no information available on the 'best' way to configure this. I should note that my development...
16
by: Martin Jørgensen | last post by:
Hi, Problem: ======== Some of my output functions are beginning to take pretty many arguments... I mean.... We're talking about 10-15 arguments :-) So I thought to myself, perhaps this is...
3
by: André | last post by:
Hi, I put that question already, but it's still not very clear to me, so ... Assume following option in web.config= debug="false" but in one aspx page (test.aspx) <%@ debug="true" ..%>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.