<?php
class SimpleClass {
public const COSNTANT = "costant value";
private $var = "a default value";
function __construct($var) {
$this->var = $var;
}
public function getVar() {
return $this->var;
}
public function setVar($var) {
$this->var = $var;
}
public function toString() {
echo $this->var;
}
}
$test = new SimpleClass("test2");
$test->setVar("test");
$test->toString();
echo SimpleClass::CONSTANT;
test
Fatal error: Uncaught Error: Undefined constant SimpleClass::CONSTANT in /in/rUDbI:27
Stack trace:
#0 {main}
thrown in /in/rUDbI on line 27
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
test
Fatal error: Uncaught Error: Undefined constant SimpleClass::CONSTANT in /in/rUDbI:27
Stack trace:
#0 {main}
thrown in /in/rUDbI on line 27
Process exited with code 255.
test
Fatal error: Uncaught Error: Undefined class constant 'CONSTANT' in /in/rUDbI:27
Stack trace:
#0 {main}
thrown in /in/rUDbI on line 27
Process exited with code 255.