Skip to content

Instantly share code, notes, and snippets.

@andyfriesen
Created February 7, 2014 00:53
Show Gist options
  • Save andyfriesen/8855570 to your computer and use it in GitHub Desktop.
Save andyfriesen/8855570 to your computer and use it in GitHub Desktop.
PHP, __call and access protection.
<?php
class B {
public function __call($fn, $args) {
$c = array($this, 'hello');
$c();
}
private function hello() {
echo "hello B\n";
}
private function goodbye() {
echo "goodbye B\n";
}
}
$b = new B;
$b->hello();
$fn = array($b, 'goodbye');
$fn();
hello B
hello B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment