Longhorn PHP 2025 - Call For Papers

Voting

: zero minus zero?
(Example: nine)

The Note You're Voting On

Abhi Beckert
15 years ago
Beware that this does not behave as expected if your method is not declared as static! For example:

<?php

class foo {
static public function
test() {
var_dump(get_called_class());
}

public function
testTwo() {
var_dump(get_called_class());
}
}

class
bar extends foo {
}

class
abc {
function
test() {
foo::test();
bar::test();
}

function
testTwo() {
foo::testTwo();
bar::testTwo();
}
}

echo
"basic\n";
foo::test();
bar::test();

echo
"basic without static declaration\n";
foo::testTwo();
bar::testTwo();

echo
"in a class\n";
$abc = new abc();
$abc->test();

echo
"in a class without static declaration\n";
$abc->testTwo();

?>

The result is:

basic
string 'foo'
string 'bar'

basic without static declaration
string 'foo'
string 'bar'

in a class
string 'foo'
string 'bar'

in a class without static declaration
string 'abc'
string 'abc'

<< Back to user notes page

To Top