FAQ
Consider the following:

$x = FALSE;
$x || throw new exception('Some Assertion');

I get the following Parse Error:
error: parse error, unexpected T_THROW in /home/.../Z_Record.php on line 153


However, this code produces no errors..

$x = FALSE;
$x || exit;


Why is this?

Thanks,
Jason Garber

Search Discussions

  • Antony Dovgal at Jun 17, 2004 at 6:21 am

    On Thu, 17 Jun 2004 02:17:26 -0400 Jason Garber wrote:

    Consider the following:
    Why is this?
    Take a look at the bug #28727:
    http://bugs.php.net/?id=28727

    ---
    WBR,
    Antony Dovgal aka tony2001
    tony2001@phpclub.net || antony@dovgal.com
  • Jason Garber at Jun 17, 2004 at 6:34 am
    That's what I figured. throw is a language construct.

    However, from the manual (http://php.net/exit):

    void exit ( int status)
    Note: This is not a real function, but a language construct.


    Why does

    $x || exit;

    work without a parse error?

    Thanks,
    Jason Garber

    At 6/17/2004 10:22 AM +0400, Antony Dovgal wrote:
    On Thu, 17 Jun 2004 02:17:26 -0400
    Jason Garber wrote:
    Consider the following:
    Why is this?
    Take a look at the bug #28727:
    http://bugs.php.net/?id=28727

    ---
    WBR,
    Antony Dovgal aka tony2001
    tony2001@phpclub.net || antony@dovgal.com

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Joseph Lee at Jun 17, 2004 at 11:22 am
    I guess "exit();" terminates execution within itself without returning
    to the caller, so that is no chance of getting a runtime error.

    For example, " return ( exit() ); " is wrong, but works.


    Joe Lee



    -----Original Message-----
    From: Jason Garber
    Sent: Thursday, June 17, 2004 7:34 AM
    To: internals@lists.php.net
    Subject: Re: [PHP-DEV] Throw Question


    That's what I figured. throw is a language construct.

    However, from the manual (http://php.net/exit):

    void exit ( int status)
    Note: This is not a real function, but a language construct.


    Why does

    $x || exit;

    work without a parse error?

    Thanks,
    Jason Garber

    At 6/17/2004 10:22 AM +0400, Antony Dovgal wrote:
    On Thu, 17 Jun 2004 02:17:26 -0400
    Jason Garber wrote:
    Consider the following:
    Why is this?
    Take a look at the bug #28727:
    http://bugs.php.net/?id=28727

    ---
    WBR,
    Antony Dovgal aka tony2001
    tony2001@phpclub.net || antony@dovgal.com

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Hartmut Holzgraefe at Jun 17, 2004 at 12:13 pm

    Joseph Lee wrote:
    I guess "exit();" terminates execution within itself without returning
    to the caller, so that is no chance of getting a runtime error.
    parse error != runtime error

    but language constructs like exit, unset and print are especialy
    ment to be as function-like as possible, thats why you can use
    them in expressions ...

    --
    Hartmut Holzgraefe <hartmut@php.net>
  • Jason Garber at Jun 18, 2004 at 1:00 am
    Thanks for the good explanation.

    ~Jason
    At 6/17/2004 02:10 PM +0200, Hartmut Holzgraefe wrote:
    Joseph Lee wrote:
    I guess "exit();" terminates execution within itself without returning
    to the caller, so that is no chance of getting a runtime error.
    parse error != runtime error

    but language constructs like exit, unset and print are especialy
    ment to be as function-like as possible, thats why you can use
    them in expressions ...

    --
    Hartmut Holzgraefe <hartmut@php.net>

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJun 17, '04 at 6:17a
activeJun 18, '04 at 1:00a
posts6
users4
websitephp.net

People

Translate

site design / logo © 2019 Grokbase