javascript与PHP动态往类中添加方法对比
1.JAVASCRIPT:
a.代码:
vara=function(){ } varmy_a=newa() my_a.say=function(){ console.log('hello') } my_a.say()
b.输出:
hello
2.PHP:
a.代码:
say=function(){ echo"hello"; }; $say=$a->say; $say();
b.输出:
hello
1.JAVASCRIPT:
a.代码:
vara=function(){ } varmy_a=newa() my_a.say=function(){ console.log('hello') } my_a.say()
b.输出:
hello
2.PHP:
a.代码:
say=function(){ echo"hello"; }; $say=$a->say; $say();
b.输出:
hello