Answer the question
In order to leave comments, you need to log in
A static call to a non-static method fires, how so?
There are non-static methods - test1 and test2
When they are called statically, they work as static ones, what's the catch?
class Test {
public function test(){
echo 'ты меня видишь';
}
public function test2(){
echo 12;
}
}
$d = Test::test1(); // выводит: ты меня видишь
$a = Test::test2(); // выводит: 12
Answer the question
In order to leave comments, you need to log in
sandbox.onlinephpfunctions.com
checked your code.
It throws a Warning, but the code executes.
Such is our PHP.
<br />
<b>Strict Standards</b>: Non-static method Test::test1() should not be called statically in <b>[...][...]</b> on line <b>11</b><br />
ты меня видишь<br />
<b>Strict Standards</b>: Non-static method Test::test2() should not be called statically in <b>[...][...]</b> on line <b>12</b><br />
12
The method does not use object data, so nothing prevents it from being called statically. If inside there was a call to the field through $this, then an error would pop up.
And yes, it's PHP...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question