SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    no print on die($num) but die($num.'a') works?

    is there a reason php won't display an integer in a die() function?

    PHP Code:
    //won't work
    if (1==1$next_num 9;
    die(
    $next_num);

    //won't work
    do{ $next_num 1;}while(== 2);
    die(
    $next_num);

    //works
    if (1==1$next_num 9;
    die(
    $next_num.'a');

    //works
    do{ $next_num 1;}while(== 2);
    die(
    $next_num.'a');

    //works
    $next_num 9;
    die(
    $next_num); 
    it seems to only happen if the variable was instantiated in an if statement or loop

    php 4.3.1
    apache 1.27.x
    tested in ie 6

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    die is an alias for exit.
    http://php.net/exit
    Quote Originally Posted by PHP Manual
    exit

    (PHP 3, PHP 4 )
    exit -- Output a message and terminate the current script
    Description
    void exit ( [string status])

    void exit ( int status)

    Note: This is not a real function, but a language construct.

    The exit() function terminates execution of the script. It prints status just before exiting.

    If status is an integer, that value will also be used as the exit status. Exit statuses should be in the range 1 to 254, the exit status 255 is reserved by PHP and shall not be used.

    Note: PHP version >= 4.2.0 does NOT print the status if it is an integer.

    Note: The die() function is an alias for exit().
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •