關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • PHP 的單引號與雙引號的分別

    Posted on January 14th, 2007 Sam Tang 1 comment

    在 PHP 定義字串給變數及印出字串時都要用引號,單引號及雙引號也可以做到,而它們的分別是這樣:

    PHP 會解譯雙引號內的變數,而單引號內的則不會,只把單引號內的內容視作字串,包括 "$" 符號,所以如果是單純的字串,那麼執行上單引號會比雙引號較快。

    參考文章: 10 Tips That Every PHP Developer Should Know, Part 2


     

    One response to “PHP 的單引號與雙引號的分別”

    1. [...] PHP 的單引號與雙引號的分別 – Real-Blog (tags: Tech WebDev PHP Tips) [...]

    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word