2
In PHP, we have some special methods that can be included in a class.
One of them is the __call, that causes an action to be invoked (through it) when a method does not exist in a class.
Example:
class Exemplo
{
public function existe()
{
echo 'Eu existo';
}
public function __call($method, $parameters)
{
echo "$method não existe, mas vou fazer alguma coisa legal";
}
}
$e = new Exemplo;
$e->existo(); // 'Eu existo'
$e->nao_existo(); // "nao_existo não existe, mas vou fazer alguma coisa legal"
In javascript there is some way to do this?
Example:
function special(){}
special.prototype.existe = function () {
console.log('Esse método existe');
}
Funny: Why Firefox always has one thing that others don’t. Another example is the
toSource– Wallace Maxters
Mozilla actively participates in the development of new web technologies, they usually implement very new features of the latest specifications.
– Bernardo Botelho