any way to add new method to an object in php such as javascript?
in javascript we can extend an js obj like this
var o={};
o.test1 = function(){...}
how to do it in php? please see my code bellow:
<?php
class a{
function test(){
echo 'hello';
}
}
$var= new a;
// I want to add a new method fo $var
// .... how to extend $var here ?
$var->test1(); // world
// placeholder
// placeholder
// placeholder
// placeholder
// placeholder
// placeholder
// placeholder