我有5個參數和默認站點的功能寬度可變獲取函數的參數值PHP
$site_width ='1000px';
function MyPrintFunction ($divName,$width=false,$html1='',$html2='', $echo = true){
... plenty of code above, no need to post complete function
$html = '<div id="'.$divName.'">';
$html .= '</div>';
if($echo){
echo $html1.$html.$html2;
}else{
return $html1.$html.$html2;
}
}
,比我打印HTML這樣的:
MyPrintFunction ('divname1',true);
MyPrintFunction ('divname2');
MyPrintFunction ('divname3');
我需要檢查是否有這些功能已經將第二個參數設置爲true,如果是,我需要第一個參數名稱。
這樣我可以添加參數名稱的CSS代碼段(將在後面的頭被注入),並設置寬度爲它
#ARrument1NameSHouldGoHereAsVariable{
width:$site_width;
}
我希望我解釋了這一權利。對不起,如果我沒有。任何幫助表示讚賞。謝謝!
@ L0j1k不知道我明白 – Benn
如果你在那裏創建div,爲什麼不把寬度作爲div的'style'呢?看起來這會更容易。 –
@ G-Nugget哈哈,你有我了,我已經有了它的功能,並且想把它從內聯中取出並放在它所屬的地方,
– Benn