Bug #71461 [Opn->Nab]: Able to access private property outside class

From: Date: Wed, 27 Jan 2016 09:56:36 +0000
Subject: Bug #71461 [Opn->Nab]: Able to access private property outside class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198919@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71461&edit=1 ID: 71461 Updated by: chx@php.net Reported by: vikashchaudhary10 at gmail dot com Summary: Able to access private property outside class -Status: Open +Status: Not a bug Type: Bug -Package: PHP Language Specification +Package: Scripting Engine problem Operating System: Linux Ubuntu 15.10 PHP Version: 7.0.2 Block user comment: N Private report: N New Comment: You are adding new properties to the class not accessing the parent properties. Previous Comments: ------------------------------------------------------------------------ [2016-01-27 09:51:55] vikashchaudhary10 at gmail dot com Description: ------------ I have a class having two private property named name and age. I have created object outside of class and able to access those private property outside class. Please look into this issue also let us know why is it working properly? Test script: --------------- <?php class Person { private $name; private $age; } class Student extends Person { public $rollNo; public $marks; } $object = new Student(); $object->name = 'Vikash'; $object->age = 30; echo $object->name; Expected result: ---------------- Must through fatal error Actual result: -------------- Vikash ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71461&edit=1

« previous php.bugs (#198919) next »