Code equivalence between Javascript and PHP
- by xdevel2000
I'm trying to learn PHP and I wish to know if there are some function equivalence constructs:
In JS I can do:
var t = function() {};
t();
myObj.DoStuff = function() {} // here I add a method at run-time
myObj.DoStuff();
myObj["DoStuff"]();
var j = myObj.DoStuff;
j();
and so other things with function evaluation.
In Js objects are associative arrays so every properties is accessible with
the subscript notation...
Can I add a method at run-time to a class template so next its object instances can have it?
In JS I can do that via a prototype function property.