我对此进行了研究,找不到我想要的东西。
class headerStyle{
// now creating our CONSTRUCTOR function
function __construct($args=array()) {
$this->fields = array('background','color','fontSize','backgroundUrl','imagePosition','Width','Height','backgroundSize','margin','padding','backgroundRepeat');
foreach ($this->fields as $field) {
$this->{"$field"} = $args["$field"];
}
}
}
$style = new headerStyle(
array(
background =>"#DEDEDC",
color=>"#F5F3F4",
fontSize=>"24px",
backgroundUrl=>"_images/bodyBg1.jpg",
backgroundSize=>"50% 50%",
padding=>"10px 0px 0px 0px",
margin=>"0px 0px 0px 0px",
width=>"100%",
height=>"60px",
imagePosition=>"top-left",
)
);
我需要传递一个动态变量,而不是给出一个值,例如 background=>$_post['headerBg'];