PHP 8.5.0 Beta 1 available for testing

Voting

: max(zero, four)?
(Example: nine)

The Note You're Voting On

aabweber at gmail dot com
3 years ago
Simplest way to understand is to run this script:

<?php
class ParentClass
{
static
$A = 'ParentVariable';

static function
parentCall()
{
echo
get_called_class() . ', self: ' . self::$A . "\n";
echo
get_called_class() . ', static: ' . static::$A . "\n";
echo
"---\n";
}
}

class
ChildClass extends ParentClass
{
static
$A = 'ChildVariable';

static function
childCall()
{
echo
get_called_class() . ', self: ' . self::$A . "\n";
echo
get_called_class() . ', static: ' . static::$A . "\n";
echo
get_called_class() . ', parent: ' . parent::$A . "\n";
echo
"---\n";
}
}

echo
"Late Static Bindings:\n";
ParentClass::parentCall();
ChildClass::parentCall();
ChildClass::childCall();
?>

----
Output:

Late Static Bindings:
ParentClass, self: ParentVariable
ParentClass, static: ParentVariable
---
ChildClass, self: ParentVariable
ChildClass, static: ChildVariable
---
ChildClass, self: ChildVariable
ChildClass, static: ChildVariable
ChildClass, parent: ParentVariable

<< Back to user notes page

To Top