> -----Original Message-----
> From: Bob McConnell [mailto:r...@cbord.com]
> Sent: Friday, February 27, 2009 7:44 AM
> To: h.schult...@yahoo.com; a...@ashleysheridan.co.uk
> Cc: php-general@lists.php.net; 9el
> Subject: RE: [PHP] "use strict" or similar in PHP?
> From: Hans Schultz
> >
> > Hahahah,I was thinking the same thing :D
> >
> > --- On Fri, 2/27/09, Ashley Sheridan <a...@ashleysheridan.co.uk>
> wrote:
> > From: Ashley Sheridan <a...@ashleysheridan.co.uk>
> > Subject: Re: [PHP] "use strict" or similar in PHP?
> > To: "Hans Schultz" <h.schult...@yahoo.com>
> > Cc: php-general@lists.php.net, "9el" <le...@phpxperts.net>
> > 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
> > 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

A la Pascal? What?! :D I had always thought when hit F9 in my Borland
studio back in the day that it built me a pretty little EXE file.

> 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
> induce PHP to completely parse the source file(s) and report any
> before printing out anything, even the HTTP headers? Or can I set it
> redirect to an error page instead of sending an incomplete target page
> with error messages that might reveal information I don't want

Well, take care of all of your logic before you display anything. It's
not that difficult, to be honest... especially if you're already using
an MVC design pattern/framework or a template system. If you are just
worried about displaying garbage and not about performing logic while
the page is being output to the browser, then I'd say use an output
buffer. If something bad happens, just clear the buffer out rather than
send it to the user, and forward to your error page instead.



// Todd

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

Reply via email to