Bug #71461 [Com]: Able to access private property outside class
| From: | ragafa5955 at glalen dot com | Date: | Fri, 10 Nov 2023 15:25:46 +0000 |
| Subject: | Bug #71461 [Com]: Able to access private property outside class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-245786@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
Comment by: ragafa5955 at glalen dot com
Reported by: vikashchaudhary10 at gmail dot com
Summary: Able to access private property outside class
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Linux Ubuntu 15.10
PHP Version: 7.0.2
Block user comment: N
Private report: N
New Comment:
<
Previous Comments:
------------------------------------------------------------------------
[2016-01-27 09:56:35] chx@php.net
You are adding new properties to the class not accessing the parent properties.
------------------------------------------------------------------------
[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