I need to use PHP constant in a static variable but I discover today that it's not possible : Is a global PHP CONSTANT available inside of a Class file?
define("TABLE_PREFIX", "TEST_");
class Test {
private static $sql_query = "select * from ".TABLE_PREFIX."USER";
public static function show_query1() {
echo "My first test";
echo self::$sql_query;
}
public static function show_query2() {
echo "My second test";
echo self::$sql_query;
}
}
Test::show_query1();
Test::show_query2();
I don't want to pass the constant as an argument to the static function and I don't want to declare $sql_query in each static function.
What is the best way to to it ?
EDIT : add demo = http://codepad.org/aqzj2TJh
"concatenated"."strings".