Forum Moderators: coopster

Message Too Old, No Replies

PHP Validators

... online checkers.

         

internetheaven

11:35 pm on Jan 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know of a few HTML validators, does anyone know an online (free) php validator? My coding seems to be jamming but I can't determine the exact line where the extra/missing piece is!

storevalley

11:38 pm on Jan 8, 2005 (gmt 0)

10+ Year Member



Building some logging (e.g. to a text file) is a pretty good way of working out where a script is falling to bits ...

coopster

11:50 pm on Jan 8, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you tried any of the tips in the PHP Troubleshooting [webmasterworld.com] guide found in the Forum Library [webmasterworld.com]?

jbinbpt

12:33 am on Jan 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try HTML-Kit. It claims to validate php using html-tidy.

jshpro2

11:29 pm on Jan 10, 2005 (gmt 0)

10+ Year Member



Put error_reporting(E_ALL);

Does it give you any parse errors?

PHP can only tell you about certain errors.
For example if you put:
$a=11;
When you meant
$a=0;
And for some reason your script jams up, PHP can't tell you it was because $a had the wrong value, you have to manually figure that out yourself.

If you still can't figure it out .zip up the whole script and let me take a look at it, I'll have a look at it and see if I can tell you whats goin wrong.

mincklerstraat

1:00 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only real kind of php validator is inside PHP itself - the parsing engine, the same thing that interprets PHP. So using error_reporting(E_ALL); during development (ditch this for production) is really what you need to do.

Besides this, an editor that can show you line numbers and syntax highlighting can get you very far in validation steps. It will show you where strings begin and end, and where they are properly closed or not; good ones will show you where brackets/braces/parentheses are matched, or not. Jedit is what I usually recommend for this kind of thing; HTML-Kit is cool, but over multiple lines of code I've been less than pleased with the syntax highlighting. I also don't use windows much any more really and jedit is available on many different platforms. The editor I actually use most lately is Kate, but that's *nix only, I'm afraid.

ergophobe

8:34 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



HTML-Kit with Tidy does not validate PHP, it validates the HTML produced by the PHP script.

There's no such thing as PHP validation per se. Properly speaking, that is a term that pertains to SGML languages and such.

One could say that parsing HTML is a sort of validation as Minck said, but you know your PHP is valid in that respect or you get parse errors and the script crashes.

So, the best things you can do are

- run with E_ALL as Mincklerstraat said in the previous post

- get an editor with brace matching and syntax highlighting. When you find yourself saying "Hey the syntax highlighting for this program is screwed up" it's likely that the program is fine ;-) Some that have it that I know of are Kommodo, HAPEdit, NVU, TextPad, Context and many many others. Please do a google search for it since you'll find very long threads on the subject.

- run a debugger/profiler. There are a few. I sometimes (rarely actually) use xdebug. Kommodo comes packaged with a good one. php-debugger is suposed to be good but I've never gotten it to work. It's supposed to be integrated with one of the free php editors but I don't remember which one.