|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-06 17:29 UTC] tornike dot comaia dot mail at gmail dot com
[2015-06-10 00:34 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2015-06-10 00:34 UTC] cmb@php.net
[2015-06-10 00:34 UTC] cmb@php.net
-Summary: protected property can be accesed from
another class that has the same parent
+Summary: protected property can be accessed from
another class that has the same parent
-PHP Version: 5.5.26RC1
+PHP Version: 5.6.9
[2016-03-27 16:16 UTC] nikic@php.net
-Status: Verified
+Status: Duplicate
[2016-03-27 16:16 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 21:00:02 2025 UTC |
Description: ------------ It is possible to access the protected property of class A within the class B if both classes have the same parent - C, that defined the property unless the property is overriden in child class A or B Test script: --------------- <?php class C { protected $data; } class A extends C { } class B extends C { public function test() { $obj = new A(); $obj->data = 'Hello world'; echo $obj->data; } } ?> Expected result: ---------------- Unless the class B is not the child of the class A, an error must be risen when trying to access the protected property of the class A within class B