A similar question discusses __construct, but I left it in my title for people searching who find this one.
Apparently, __get and __set take a parameter that is the variable being gotten or set. However, you have to know the variable name (eg, know that the age of the person is $age instead of $myAge). So I don't see the point if you HA...
Let's say I want to create the alias %xed for %edit -x. How would I do it?
...
I would like to know if it's possible to create a magic object that extends another magic object, (with PHP).
...
It should not be __isset,because isset() is not the same thing as empty()
...
I am using a magic getter/setter class for my session variables, but I don't see any difference between normal setters and getters.
The code:
class session
{
public function __set($name, $value)
{
$_SESSION[$name] = $value;
}
public function __unset($name)
{
unset($_SESSION[$name]);
}
publi...
In Mercurial, many of the extensions wrap their help/syntax string in a call to an underscore function, like so:
_('[OPTION] [QUEUE]')
This confuses me, because it does not seem necessary (the Writing Extensions instructions don't mention it) and there doesn't seem to be a _ defined in the class, so I'm wondering if this is some spec...
The magic function __call() in php are used in classes. Are there any similar magic function but for functions instead? Like __autoload() is for functions.
For example something like this
function __call($name, $arguments) {
echo "Function $name says {$arguments[0]} ";
}
random_func("hello");
...