javascript与php动态往类中添加方法
更新:HHH 时间:2023-1-7
|
- JAVASCRIPT:
a. 代码:
var a = function(){
}
var my_a = new a()
my_a.say = function(){
console.log('hello')
}
my_a.say()
b. 输出:
hello
- PHP:
a. 代码:
<?php
class a{
}
$a = new a();
$a->say = function(){
echo "hello";
};
$say = $a->say;
$say();
b. 输出:
hello
|