PHP 8.5.0 Beta 1 available for testing

Voting

: min(one, seven)?
(Example: nine)

The Note You're Voting On

delete dot this dot and dot dots dot gt at kani dot hu
11 years ago
I think it's useful if we draw some attention to late static binding here:
<?php
class A {
const
MY_CONST = false;
public function
my_const_self() {
return
self::MY_CONST;
}
public function
my_const_static() {
return static::
MY_CONST;
}
}

class
B extends A {
const
MY_CONST = true;
}

$b = new B();
echo
$b->my_const_self ? 'yes' : 'no'; // output: no
echo $b->my_const_static ? 'yes' : 'no'; // output: yes
?>

<< Back to user notes page

To Top