<?php
final class Example
{
private $variable;
public function __construct($variable)
{
$this->variable = fopen('php://memory', 'rw+');
fwrite($this->variable, $variable);
}
public function example()
{
return file_get_content($this->variable);
}
public function setExample($variable)
{
fwrite($this->variable, $variable);
}
public function __destruct()
{
fclose($this->variable);
}
}
$example = new Example('first');
print $example->example() . PHP_EOL;
$example->setExample('second');
print $example->example() . PHP_EOL;
Fatal error: Uncaught Error: Call to undefined function file_get_content() in /in/bGf5k:15
Stack trace:
#0 /in/bGf5k(31): Example->example()
#1 {main}
thrown in /in/bGf5k on line 15
Process exited with code 255.
Strict Standards: Redefining already defined constructor for class Example in /in/bGf5k on line 13
Fatal error: Call to undefined function file_get_content() in /in/bGf5k on line 15
Process exited with code 255.
Output for 5.1.3
Strict Standards: Redefining already defined constructor for class Example in /in/bGf5k on line 13
Warning: fopen(php://memory): failed to open stream: Inappropriate ioctl for device in /in/bGf5k on line 9
Warning: fwrite(): supplied argument is not a valid stream resource in /in/bGf5k on line 10
Fatal error: Call to undefined function file_get_content() in /in/bGf5k on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.2
Strict Standards: Redefining already defined constructor for class Example in /in/bGf5k on line 13
Warning: fopen(php://memory): failed to open stream: Inappropriate ioctl for device in /in/bGf5k on line 9
Warning: fwrite(): supplied argument is not a valid stream resource in /in/bGf5k on line 10
Fatal error: Call to undefined function file_get_content() in /in/bGf5k on line 15
Warning: fclose(): supplied argument is not a valid stream resource in /in/bGf5k on line 25
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/bGf5k on line 3
Process exited with code 255.