<?php
class SEGV {
private $obj;
public function __construct() { } // there should be construct to get SEGV
public function segv() {
$this->obj->attribute = "TEST";
}
public function getObj() {
return $this->obj;
}
}
$s = new SEGV;
//$s->segv(); // if value of obj is set from the inside of class, it will not get SEGV.
$s->getObj()->attribute["TEST"] = "TEST"; // member value is set from the outside of class
$s->segv(); // this set function will get SEGV
$s->segv();
echo "SUCCESS\n";
Fatal error: Uncaught Error: Attempt to modify property "attribute" on null in /in/5UBQi:18
Stack trace:
#0 {main}
thrown in /in/5UBQi on line 18
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Creating default object from empty value in /in/5UBQi on line 18
Warning: Creating default object from empty value in /in/5UBQi on line 8
SUCCESS
Warning: Creating default object from empty value in /in/5UBQi on line 8
SUCCESS
Output for 5.3.3 - 5.3.29
Strict Standards: Creating default object from empty value in /in/5UBQi on line 8
SUCCESS
Process exited with code 139.
Output for 5.3.0 - 5.3.2
Strict Standards: Redefining already defined constructor for class SEGV in /in/5UBQi on line 7
Strict Standards: Creating default object from empty value in /in/5UBQi on line 8
SUCCESS
Process exited with code 139.
Output for 5.2.14 - 5.2.17
Strict Standards: Creating default object from empty value in /in/5UBQi on line 8
SUCCESS
Strict Standards: Redefining already defined constructor for class SEGV in /in/5UBQi on line 7
Strict Standards: Creating default object from empty value in /in/5UBQi on line 8
SUCCESS
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5UBQi on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5UBQi on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/5UBQi on line 4
Process exited with code 255.