View Single Post

  #17 (permalink)  
Old 05-12-2008
Sir Robin
 
Posts: n/a
Default Re: Tool to parse and validate PHP script?

On Sat, 10 May 2008 15:48:00 -0400, sheldonlg <sheldonlg> wrote:

>>>> Gilles Ganault wrote:
>>>>> Hello
>>>>>
>>>>> Is there a tool on Linux/FreeBSD that can parse a PHP script to
>>>>> make
>>>>> sure there's no compile-time issues?
>>>> You will never have a compile-time error with PHP since PHP is a
>>>> script and, hence, doesn't compile. Perhaps you mean run-time issues?
>>>
>>> As far as I understand PHP does in fact first compile the script to
>>> byte-code
>>> and then run it... Surely if the code has syntax errors it would
>>> result to
>>> compile time error, right?
>>>

>>
>> No, Gilles is correct. PHP is not compiled. It is interpreted. A big
>> difference. And no, syntax errors are not considered compile-time errors.
>>
>> Java, OTOH, is compiled to byte code.
>>

>
>Jerry, that was me -- not Gilles -- who said it....but thanks for
>agreeing. Robin, by compile time we mean generating code without
>running the code. That is what we mean by a differentiation between
>compile time errors and run time errors. The former does syntax
>checking, etc. and the bugs are an order of magnitude easier to find
>than run time bugs.
>An interpreted language, like PHP, doesn't have a
>compiler.


Ah yes, with this definition you are right under regular php execution -
although there is exception: When using php accelerator software there is the
difference that php bytecode is cached and after that re-compiled only if
source is modified after last runtime compiling. Technically however it is
still incorrect to say that PHP does not have a compiler - like several other
interpreted languages it has a built-in runtime compiler. It doesnt however
need compiling before running and there is no separate compiler to produce
bytecode files.

--
***/--- Sir Robin (aka Jani Saksa) Bi-Sex and proud of it! ---\***
**/ email: robsku@fiveam.NO-SPAM.org, <*> Reg. Linux user #290577 \**
*| Me, Drugs, DooM, Photos, Writings... http://soul.fiveam.org/robsku |*
**\--- GSM/SMS: +358 44 927 3992 ---/**
"Jokainen linkki, jonka päätteenä on ".org", on kelvoton tiedonlähde."
- Nikolas Mäki
Reply With Quote