Require跟Include的分別 --
以下的兩個function也會包含一個檔案到頁面中:
require_once "files";
include_once "files";
而分別是require_once()如果包含失敗,就會直接終止整個程式的運作,而include_once()會略過繼續執行。
單引號和雙引號的分別--
以下兩句也會直接輸出字串:
echo "hello world!";
echo 'hello word';
以上執行效果相同,但如果加入變數:
$name="kaon";
echo "hello world! $name"; //輸出: hello world! kaon
echo 'hello world! $name'; //輸出:hello world! $name
單引號包住的,php會示它為字串,不會進行任何解構,而雙引號就會對變數進行解構,所以如果只是打算輸出字串,請使用單引號,執行速度會比較快。
沒有留言:
張貼留言