0
I wanted to use static PHP functions as follows:
class A {
static function a1() {
echo "A1";
return A;
}
static function a2() {
echo "A2";
return A;
}
}
A::a1()::a2();
Works, but shows this error:
A1
NOTICE Use of Undefined Constant A - assumed 'A' on line number 4
A2
NOTICE Use of Undefined Constant A - assumed 'A' on line number 8
What is assumed 'A'
?
Should I return the class in another way, or create a constant with the value of class A? In this case, how?
It is correct to say that these functions follow the same Builder standard nay being builders?
It’s kind of weird, what the need to be static?
– rray
The methods would be to change the response status and to return an object or array that will be converted to json, I first did together, but would like to separate into two parts
– Costamilam
Related: What is Chaining of Methods?, Defining the chained methods of a method and What is Fluent Interface?. Maybe the first link answers your question.
– rray
@rray thanks for the links, the first only lacked show with static functions, I will read better later
– Costamilam
return A
would return a predefined constant - so the error.– Papa Charlie
@Guilhermecostamilam Has the answer solved what was in doubt? Do you need something better? Do you think it is possible to accept it now?
– Maniero
@Maniero solved the problem by returning
__CLASS__
in functions, your answer answers the second question but not the first, if you want to edit it with this solution I accept it– Costamilam