RE: "use strict" or similar in PHP?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hans Schultz
> 
> Hahahah,I was thinking the same thing :D
> 
> --- On Fri, 2/27/09, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> From: Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
> Subject: Re:  "use strict" or similar in PHP?
> To: "Hans Schultz" <h.schultz78@xxxxxxxxx>
> Cc: php-general@xxxxxxxxxxxxx, "9el" <lenin@xxxxxxxxxxxxx>
> Date: Friday, February 27, 2009, 1:11 PM
> 
> On Fri, 2009-02-27 at 14:04 +0100, Hans Schultz wrote:
>> Sorry, I didn't want to offend anyone :-) It was just very weird
> argument  
>> - to quote:
>> "There is no "compile" time.  PHP is interpreted so it is
> compiled and  
>> then executed."
>> Sounds like contradiction in this very sentence :-).
>> 
>> My apologies
>> 
> But if it never compiles, it can never run, but it can't run without
> compiling? Arggh, my head. So does that mean if I go back in time and
> shoot my grandfather, then nobody is in the woods to hear PHP try to
> compile?

The compile process parses the text of the source file and translates it
into an alternate form. This can by byte code, ala Pascal and Java, or
executable code, ala COBOL and C. An interpreter, on the other hand,
simply parses the source file, line by line and executes each line as it
reads it, usually without saving it in an alternate form. This is the
way JavaScript works. Some languages, such as Perl, are somewhere
between the two. Perl parses the whole file, then executes only if it
did not find any syntax errors or undefined variables (if certain
strictures are turned on). Otherwise it prints out only the error
message.

>From what I have seen of PHP, it is strictly interpreted. i.e. a line is
read, and executed. Then the next line is read, and executed. etc. So
there is no way to get it to block execution from the beginning even
when there are fatal errors. It will already have printed out as much of
the page as it executed before it finds those errors. This works fine in
a development or test environment, but is a serious problem in
production.

So, I believe the question that was actually asked, is there any way to
induce PHP to completely parse the source file(s) and report any errors
before printing out anything, even the HTTP headers? Or can I set it to
redirect to an error page instead of sending an incomplete target page
with error messages that might reveal information I don't want exposed?

Bob McConnell

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux