If we suppose that:
<?php
class test_class
{
private $variable_name = 'id';
private $id = 0;
}
How to acces to variable 'id' inside an instance? :
<?php
class test_class
{
private $variable_name = 'id';
private $id = 0;
function test() {
echo $this->{$this->variable_name};
}
}
$object = new test_class();
$object->test();
Best regards!
No comments:
Post a Comment