Php 如何使用参数作为对象属性?
在PHP中,我们是这样做的:Php 如何使用参数作为对象属性?,php,javascript,Php,Javascript,在PHP中,我们是这样做的: function($param) { $this->{$param}; } 我们如何在JavaScript中做到这一点?在JavaScript中,您可以这样编写 function House(rooms,price,garage) { this.rooms=rooms; this.price=price; this.garage=garage; } 在javascript中,您可以这样编写 function House(r
function($param)
{
$this->{$param};
}
我们如何在JavaScript中做到这一点?在JavaScript中,您可以这样编写
function House(rooms,price,garage) {
this.rooms=rooms;
this.price=price;
this.garage=garage;
}
在javascript中,您可以这样编写
function House(rooms,price,garage) {
this.rooms=rooms;
this.price=price;
this.garage=garage;
}
我不懂PHP,但可以使用方括号表示法访问属性
function(param)
{
this[param];
}
我不懂PHP,但可以使用方括号表示法访问属性
function(param)
{
this[param];
}
函数(param){this[param];}
。当然,如果不返回属性、设置属性或将其作为函数调用…function(param){this[param];}
,这是毫无意义的。当然,如果不返回属性、设置属性或将其作为函数调用,这是毫无意义的…$scope[campaign_type].push(data)$作用域[活动类型].推送(数据)?