#42936 [Opn->Bgs]: calling a static variables using ->

From: Date: Thu, 11 Oct 2007 23:25:05 +0000
Subject: #42936 [Opn->Bgs]: calling a static variables using ->
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118437@lists.php.net to get a copy of this message
ID: 42936 Updated by: johannes@php.net Reported By: bacrhr at gmail dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Windows XP PHP Version: 5.2.4 New Comment: The -> is for object access, but a static element belongs to the class. use self::$pp instead. Using -> for static acces would just lead to confusion. Previous Comments: ------------------------------------------------------------------------ [2007-10-11 22:34:41] bacrhr at gmail dot com Description: ------------ I could call and change static variable from object or from class Reproduce code: --------------- class A{ public static $pp; public function ch(){ $this->pp+=2; print $this->pp.'<br>'; } } $b = new A(); $b->ch(); print $b->pp; Expected result: ---------------- I expected error Actual result: -------------- output is: 2 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42936&edit=1

« previous php.bugs (#118437) next »