Code equivalence between Javascript and PHP

Posted by xdevel2000 on Stack Overflow See other posts from Stack Overflow or by xdevel2000
Published on 2010-04-09T13:44:13Z Indexed on 2010/04/09 13:53 UTC
Read the original article Hit count: 271

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about functions