Doc #79937 [Opn->Ver]: I think the function call is not stronger than the static property operator

From: Date: Thu, 06 Aug 2020 11:43:20 +0000
Subject: Doc #79937 [Opn->Ver]: I think the function call is not stronger than the static property operator
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17749@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79937&edit=1 ID: 79937 Updated by: cmb@php.net Reported by: fy dot kenny at gmail dot com Summary: I think the function call is not stronger than the static property operator -Status: Open +Status: Verified Type: Documentation Problem Package: Documentation problem -Operating System: win10 +Operating System: * -PHP Version: 7.4.8 +PHP Version: Irrelevant Block user comment: N Private report: N New Comment: To begin with, I don't think there is any "static property operator". Previous Comments: ------------------------------------------------------------------------ [2020-08-06 10:23:10] fy dot kenny at gmail dot com Description: ------------ --- From manual page: https://php.net/functions.variable-functions --- When calling static methods, the function call is stronger than the static property operator: Example #3 Variable method example with static properties <?php class Foo { static $variable = 'static property'; static function Variable() { echo 'Method Variable called'; } } echo Foo::$variable; // This prints 'static property'. It does need a $variable in this scope. $variable = "Variable"; Foo::$variable(); // This calls $foo->Variable() reading $variable in this scope. ?> Test script: --------------- <?php class Foo { static $variable = 'static property'; static function variable() { echo 'method variable called'; } } $variable = "variable"; echo "<br>" . Foo::$variable; // This prints 'static property'. It does need a $variable in this scope. // Foo::$variable; == Foo::$variable This is not appended dynamic static variable echo "<br>" . Foo::$$variable; // Foo::$$variable; == Foo::$variable This is appended dynamic static variable echo "<br>" . Foo::$variable(); // This calls $foo->Variable() reading $variable in this scope. // Foo::$variable(); == Foo::variable() ?> Expected result: ---------------- static property static property method variable called Actual result: -------------- static property static property method variable called ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79937&edit=1

« previous php.doc.bugs (#17749) next »