3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Serializable_Exception extends Exception { protected $serialized_backtrace; public function __sleep() { // If we just serialize, we lose the backtrace info completely // But we may well want to log or inspect this string later... if ( is_null($this->serialized_backtrace) ) { $this->serialized_backtrace = $this->getTraceAsString(); } return array_keys(get_object_vars($this)); } public function enhancedGetTraceAsString() { if ( isset($this->serialized_backtrace) ) { return $this->serialized_backtrace; } else { return parent::getTraceAsString(); } } } function foo($x) { throw new Serializable_Exception; } try { foo( new SimpleXMLElement('<test />') ); } catch ( Exception $e ) { echo $e->enhancedGetTraceAsString(); echo "\n -- \n"; echo unserialize( serialize($e) )->enhancedGetTraceAsString(); }
Output for git.master, git.master_jit, rfc.property-hooks
#0 /in/IHPI5(34): foo(Object(SimpleXMLElement)) #1 {main} -- #0 /in/IHPI5(34): foo(Object(SimpleXMLElement)) #1 {main}

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
26.73 ms | 405 KiB | 5 Q