javascript与PHP动态往类中添加方法对比
程序员文章站
2022-05-04 10:45:24
1.javascript:
a. 代码:
var a = function(){
}
var my_a = new a()
my_a.say = fu...
1.javascript:
a. 代码:
var a = function(){ } var my_a = new a() my_a.say = function(){ console.log('hello') } my_a.say()
b. 输出:
hello
2. php:
a. 代码:
<?php class a{ } $a = new a(); $a->say = function(){ echo "hello"; }; $say = $a->say; $say();
b. 输出:
hello
上一篇: Vue.js中前端知识点总结笔记