note 126959 added to language.oop5.late-static-bindings

From: Date: Sun, 27 Mar 2022 19:05:35 +0000
Subject: note 126959 added to language.oop5.late-static-bindings
Groups: php.notes 
Request: Send a blank email to php-notes+get-217773@lists.php.net to get a copy of this message
Simplest way to understand is to run this script: 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 ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 89.179.33.111) ---- Manual Page -- https://php.net/manual/en/language.oop5.late-static-bindings.php Edit -- https://main.php.net/note/edit/126959 Del: integrated -- https://main.php.net/note/delete/126959/integrated Del: useless -- https://main.php.net/note/delete/126959/useless Del: bad code -- https://main.php.net/note/delete/126959/bad+code Del: spam -- https://main.php.net/note/delete/126959/spam Del: non-english -- https://main.php.net/note/delete/126959/non-english Del: in docs -- https://main.php.net/note/delete/126959/in+docs Del: other reasons-- https://main.php.net/note/delete/126959 Reject -- https://main.php.net/note/reject/126959 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217773) next »