Link to home
Start Free TrialLog in
Avatar of BigglesZX
BigglesZX

asked on

A PHP4 Alternative to PHP5's php_check_syntax()?

Dear All,

Looking at the Misc page of the PHP function reference earlier, I found the page for php_check_syntax(). It looks like a very useful function, however I see that it is only for PHP5, and both my local server and my web host use PHP4. So my question is: is there some alternative code/function I could use in PHP4?

I would be very grateful for any assistance,

BigglesZX
SOLUTION
Avatar of CrYpTiC_MauleR
CrYpTiC_MauleR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

here is a quote from http://php4.globe.de/ChangeLog-5.php;

Added new functions:
dba_key_split() to split inifile keys in an array. (Marcus)
time_nanosleep() signal safe sleep (Magnus, Ilia)
headers_list(). (Sara)
php_strip_whitespace(). strip whitespace & comments from a script. (Ilia)
php_check_syntax(). check php script for parse errors. (Ilia)
image_type_to_extension(). return extension based on image type. (Ilia)
stream_socket_sendto() and stream_socket_recvfrom(). (Wez)
iconv_mime_decode_headers(). (Moriyoshi)
get_declared_interfaces(). (Andrey, Marcus)
sqlite_fetch_column_types(). (Ilia)

the php_check_syntax() function was only added in PHP5, and there is no alternative in PHP4, the only way to check the syntax would be to write or download a pretty damn complex function.

Zac Charles
Avatar of Marcus Bointon
Well you could emulate it by writing your file out and running 'php -l' on it using exec or similar, assuming that your host has a PHP CLI or CGI version available.
cryptic_mauler, while you are in the same thread as me, im sorry about that incedent before, i can explain it all to you in an email if you want?
Avatar of BigglesZX
BigglesZX

ASKER

Ah, I think I see. So setting to only show parse errors - is that effectively the same as physically reading through a script to make sure all statements are syntactically correct - in so much as you can't actually test the running of the script because you can't check external links, includes and such?
If so, I understand :-) . Thank you.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
zac_charles: What I meant in my original question was "is it possible to achieve the same functionality as php_check_syntax() by using other functions. I know it doesn't exist in PHP4, or I would be using it :-). Thank you though.

Squinky: Yes, that is an option for me. I will try it, thanks.
Squinky: I'm lagging with replies here :) . I meant above that your CLI option is possible, but looking at your latest comment I think that will work nicely for me. Many thanks.
Okay, going to split somewhat between Squinky and Cryptic_Mauler, since Squinky provided some nice code but C_M also provided a nice idea, both of which I might well use.

Thanks all, g'day.