Answer the question
In order to leave comments, you need to log in
How to track not only the name of the property, but also the name of the key - __get ()?
<?php
class Example
{
public function __get($name)
{
var_dump($name);
}
}
$a = new Example;
$a->abc['k'];
Answer the question
In order to leave comments, you need to log in
When you do $a->abc['k']
it is all executed in the following sequence ($a->__get('abc'))['k']
That is, no key is passed to the get.
And I'm 99% sure you don't really need it. What you are trying to do is black magic, for which no one will thank you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question