How does php verify that the properties of a class are private? Don't use reflexes.

how does php verify that the properties of a class are private? Don"t use reflexes.

Php
Apr.15,2022

<?php



class PTest {

    private $v;

    public function __construct(){
        $this->v=123;
    }
}


$p = new PTest();

try {
    echo $p->v;
}catch (Error $e){
    if(strstr($e->getMessage(),'access private property')){
        echo "\n";
    }
}


<?php
class someClass
{
    public function publicFunc() 
    {
    }
    private function privateFunc() 
    {
    }
}
var_dump(is_callable([new someClass,'publicFunc']));//bool(true)
var_dump(is_callable([new someClass,'privateFunc']));//bool(false)

if you just get the pulbic attribute, you can use get_class_vars outside the class

<?php

class PTest {

    private $v = 1;
    public $c = 2;
    protected $b = 3;
}

var_dump(get_class_vars(PTest::class));

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b394d7-2b8fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b394d7-2b8fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?