Skip to content

Instantly share code, notes, and snippets.

@kaja47
Created May 20, 2013 04:13
Show Gist options
  • Select an option

  • Save kaja47/5610375 to your computer and use it in GitHub Desktop.

Select an option

Save kaja47/5610375 to your computer and use it in GitHub Desktop.
PHP or: how I learned to stop worrying and define functions with reserved names
<?php
class Magic {
function _list() { return "list"; }
function _function() { return "function"; }
function _and() { return "and"; }
function __call($name, $args) { return $this->{"_$name"}(); }
}
$m = new Magic;
var_dump($m->list());
var_dump($m->function());
var_dump($m->and());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment