Skip to content

Instantly share code, notes, and snippets.

@damianoporta
Created July 27, 2016 14:38
Show Gist options
  • Save damianoporta/0ba350263cfa18cd22f34f064168060a to your computer and use it in GitHub Desktop.
Save damianoporta/0ba350263cfa18cd22f34f064168060a to your computer and use it in GitHub Desktop.
<?php
class MyClass {
private $var = 'Variabile privata';
}
$getter = function() {
return $this->var;
};
$setter = function($str) {
$this->var = $str;
};
$class = new MyClass();
// Prima del trick
var_dump($getter->call($class));
// Dopo il trick
$setter->call($class, "VARIABILE MODIFICATA!!!");
var_dump($getter->call($class));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment