When trying to derive from class Exception and access the 'string'
  property or call 'parent::__toString' PHP segfaults:

<?php
    class MyException extends Exception {
        function __toString() {
            var_dump($this->string);
        }
    }

    throw new MyException("hmm");
?>

Output:

$ php testException.php
NULL
Segmentation fault

  Or this example:

<?php
    class MyException extends Exception {
        function __toString() {
                        parent::__toString();
        }
    }

    throw new MyException("hmm");
?>

Output:

$ php testException.php
Segmentation fault


        The need for this came up when I saw that the reported exception is
        not foramted in the HTML output; it's quite hard next to impossible
        to properly read the stack trace. So my goal was to make my own
        exception and call nl2br() on the string returned from the class.

        Besides the segfaults above, is there a chance we have a nicer HTML
        formatting for reported Exceptions (while still strip those HTML
        tags from it for logging)?

        - Markus

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

Reply via email to