課程
/后端開發(fā)
/PHP
/PHP入門篇
constant這個我不太懂,constant和直接使用常量名有什么不同
2014-06-29
源自:PHP入門篇 4-4
正在回答
constant()函數(shù)和直接使用常量名輸出的效果是一樣的,但函數(shù)可以動態(tài)的輸出不同的常量,在使用上要靈活、方便。constant()可以經(jīng)過if判斷語句中獲取變量$p,到底是PI1還是PI2,然后進(jìn)行計算 if($height == "中"){ $p = "PI1"; }else if($height == "低"){ $p = "PI2"; } $area=constant($p);//獲取的時候更加方便
舉報
PHP入門教程輕松學(xué)習(xí),行業(yè)大牛幫您快速掌握PHP編程基礎(chǔ)知識。
6 回答
13 回答
8 回答
4 回答缺少中r Deny,Allow
5 回答localhost不能打開,只有test01.com和test02.com能打開
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2014-07-23
constant()函數(shù)和直接使用常量名輸出的效果是一樣的,但函數(shù)可以動態(tài)的輸出不同的常量,在使用上要靈活、方便。constant()可以經(jīng)過if判斷語句中獲取變量$p,到底是PI1還是PI2,然后進(jìn)行計算 if($height == "中"){ $p = "PI1"; }else if($height == "低"){ $p = "PI2"; } $area=constant($p);//獲取的時候更加方便