3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // classa.inc: class A { public $one = 1; public function show_one() { echo $this->one; } } // page1. $a = new A; $s = serialize($a); // store $s somewhere where page2.php can find it. file_put_contents('store', $s); // page2.php: // this is needed for the unserialize to work properly. $s = file_get_contents('store'); $a = unserialize($s); // now use the function show_one() of the $a object. $a->show_one(); ?>
Output for 7.0.0 - 7.1.0
Warning: file_put_contents(store): failed to open stream: Permission denied in /in/sp51Z on line 17 Warning: file_get_contents(store): failed to open stream: No such file or directory in /in/sp51Z on line 24 Fatal error: Uncaught Error: Call to a member function show_one() on boolean in /in/sp51Z:28 Stack trace: #0 {main} thrown in /in/sp51Z on line 28
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Warning: file_put_contents(store): failed to open stream: Permission denied in /in/sp51Z on line 17 Warning: file_get_contents(store): failed to open stream: No such file or directory in /in/sp51Z on line 24 Fatal error: Call to a member function show_one() on boolean in /in/sp51Z on line 28
Process exited with code 255.
Output for 5.2.3 - 5.5.35
Warning: file_put_contents(store): failed to open stream: Permission denied in /in/sp51Z on line 17 Warning: file_get_contents(store): failed to open stream: No such file or directory in /in/sp51Z on line 24 Fatal error: Call to a member function show_one() on a non-object in /in/sp51Z on line 28
Process exited with code 255.
Output for 5.0.0 - 5.2.2
<br /> <b>Warning</b>: file_put_contents(store) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Read-only file system in <b>/in/sp51Z</b> on line <b>17</b><br /> <br /> <b>Warning</b>: file_get_contents(store) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in <b>/in/sp51Z</b> on line <b>24</b><br /> <br /> <b>Fatal error</b>: Call to a member function show_one() on a non-object in <b>/in/sp51Z</b> on line <b>28</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/sp51Z</b> on line <b>5</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/sp51Z</b> on line <b>5</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/sp51Z</b> on line <b>5</b><br />
Process exited with code 255.