php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71461 Able to access private property outside class
Submitted: 2016-01-27 09:51 UTC Modified: 2016-01-27 09:56 UTC
From: vikashchaudhary10 at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.2 OS: Linux Ubuntu 15.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vikashchaudhary10 at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-27 09:51 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-27 09:56 UTC] chx@php.net
-Status: Open +Status: Not a bug -Package: PHP Language Specification +Package: Scripting Engine problem
 [2016-01-27 09:56 UTC] chx@php.net
You are adding new properties to the class not accessing the parent properties.
 [2023-11-10 15:25 UTC] ragafa5955 at glalen dot com
<
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC