SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exiting a script...

    Hello,

    How is the following script output:

    PHP Code:
    <?php
    echo "PHP 1 ";
    $x 1;
    if (
    $x)
    {
       exit;
    }
    ?>

    <p>HTML 1</p>

    <?php
    echo "PHP 2 ";
    ?>

    <p>HTML 2</p>
    A- The output is : PHP 1 <p>HTML 1</p><p>HTML 2</p> since the php script exited after the exit function and so the second PHP segment is not executed but the HTML (outside PHP) is output.

    OR B- The output is: PHP 1 since after it saw the exit; it output all the preceeding outputs and closes the connection so that even the HTML is not output.

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Nothing, even html is output after die() or exit;
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Addict CVPer's Avatar
    Join Date
    Sep 2007
    Location
    Vancouver, BC, Canada
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    B, just as what you wrote
    * @location Vancouver, BC, Canada
    * @name Steve
    * @job PHP/MySQL, Drupal, WordPress Developer


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
  •