Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

php problem, exit function.

  • 28-07-2006 11:54pm
    #1
    Registered Users, Registered Users 2 Posts: 689 ✭✭✭


    Hi

    Does the exit command in php completely stop the php processing and should it cause html outside php tags to NOT be included in a served up file?

    The closing body and html tags aren't included in the served up page because of the php exit command EVEN THOUGH the missing text is outside the php tags. Is this supposed to happen?

    PHP Source
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?php echo 'Section 1<br>'; ?>

    <?php exit("Dead<br>");
    echo 'Section 1.5<br>'; ?>

    <?php echo 'Section 2<br>'; ?>

    </body>
    </html>


    PHP Output (to the browser)
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    Section 1<br>Dead<br>


    Any help would be very handy.
    Cheers
    Joe


Comments

  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    You can attempt to use return() instead of exit, but I don't think it'll work.

    You're better of using conditionals to control what's being output.


  • Closed Accounts Posts: 22,479 ✭✭✭✭philologos


    I'm nearly sure that exit(); was replaced with die(); at some point.
    Exit and Die are both meant to stop the PHP file from processing yes and why do you need so many <?php tags right beside eachother why not use one for the whole lot

    Seamus is right though, you should use conditionals (if's or switch) unless its absolutely neccessary to use die


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    I think die() and exit() are pretty much equivalent.

    die() is pretty much meant to be used in cases where processing can't or shouldn't continue. For example, if you detect that someone has passed malicious arguments to your script. It's quite often used in database-driven sites if the script fails to connect to the database or server - if the script continues processing, it may output errors and warnings which would reveal variable names and details of your code.
    Better off to simply issue a die() with a message to the user.


  • Closed Accounts Posts: 22,479 ✭✭✭✭philologos


    yeah i've only ever seen die beside MYSQL connections or socket connections


Advertisement