PHP Error: Exception thrown without a stack frame in Unknown on line 0[reprint],thrownstack_php Tutorial

Source: Internet
Author: User
Tags php error

PHP Error: Exception thrown without a stack frame in Unknown on line 0[reprint],thrownstack


From: NetEase Blog

As far as I know, in both cases PHP will report Exception thrown without a stack frame in Unknown on line 0 error:

1) Abnormal capture with Set_exception_handler guide, exception inside perform another exception

As in the following code, this problem occurs:

http://de.php.net/manual/de/function.set-exception-handler.php#88082

  function  Error_Handler ( $code ,  $message ,  $file ,  $line  ) {  if  (0 = =  error_reporting   ())  return  ;   throw   new  errorexception ( $message , 0,  $code ,  $file ,  $line  );}   function  exception_handler ( $e  ) { //  ... normal exception Stuff goes here   print   $undefined ; //  This is the underlying problem  }   set_error_handler  ("Error_Handler" );   Set_exception_handler  ("Exception_handler" );   throw   New   Exception  ("Just Invoking the exception handler"); 

Print $undefined in the Exception_handler function; the line itself throws an exception, and he goes back to calling Set_exception_handler's Exception_handler function, which is a dead loop.

Workaround: Do not perform another exception in one exception

The above problem can be used in a try ... catch way, such as exception_handler change to the following:

function exception_handler ($e) {    try    {        //  ... normal exception stuff goeshere        print$undefined// This is the Underlying problem    }    catch (Exception$e)    {         Print Get_class ($e). " Thrown within the exception handler. Message: ". $e->getmessage (). "On line". $e-GetLine ();    }}

2) Throwing an exception in a destructor

Refer to this bug:http://bugs.php.net/bug.php?id=33598

The following code will report this error:

class Test {    function  __construct () {        echo "construct\n";    }     function greet () {        echo "Hello world\n";    }      function __destruct () {        echo "destruct\n";         Throw New Exception (' Test ' );}    } $test New test (); $test->greet ();

Current Solutions:

1. Do not throw an exception in a destructor.

2. Because the destructor is executed at exit, manually unset the kind and catch the exception.

For example above, in the last add a line unset ($test), then the program will be reported throw new Exception (' Test '); This line has errors, and then catch this exception on the line.

The above two cases will appear in PHP 5.2.11, as for reasons I think PHP may be this way, PHP bug 33598 in 2005, the bug status is closed, stating that the official does not think that this is a bug, or improper handling of a bug.


What's wrong with me opening the session?

If the file is not contained by another file, it is called: You can try the following procedure.

The file is not encoded with UTF-8.

Move your code below to the top. Anyway, there is no HTML code in the PHP file you included.

Check your php.ini note the path where the SESSION temporary file is saved and whether it can be accessed by PHP.

Why does thinkphp have garbled characters when reading SQLite data? Pointing

Coding is different, some utf-8, some Unicode, so will appear as garbled, inserted into the database when set to Utf-8, read out also use Utf-8 on the line.

http://www.bkjia.com/PHPjc/850752.html www.bkjia.com true http://www.bkjia.com/PHPjc/850752.html techarticle PHP Error: Exception thrown without a stack frame in Unknown on line 0[reprint],thrownstack from: NetEase blog on the current I understand, in two cases, PHP will report Except Io ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.