I have two static properties I would like to access outside of a class, the second of which I would like to concatenate with the first.
Ex:
<?php
class Constants {
public static $varToConcat = "bar";
public static $concat = "foo " . self::$varToConcat; // <-- How to concatenate?
}
echo Constants::$concat;
?>
The above gives the error:
PHP Fatal error: Constant expression contains invalid operations in ...../Constants.php on line 4
I've tried:
public static $concat = "foo " . $varToConcat;
public static $concat = "foo " . self::$varToConcat;
public static $concat = "foo " . $this->varToConcat;
How can this be done?