2012-03-29 118 views
0

在PHP imagettftext中,我應該能夠使用像這樣的字符串中的「\ n」換行符嗎?imagettftext \ n換行符拼圖

// The text to draw 
$text = 'Something\nElse'; 

當我嘗試這個,輸出的文字寫着「東西\\ nElse」與2回n個前斜線。

這不會導致換行。

首先,應該使用單斜槓n進行換行符(\ n)?其次,我如何得到它的工作?

感謝

回答

4

\n是一個換行符only when the string is delimited with double quotes

echo 'Something\nElse'; // outputs Something\nElse 
echo "Something\nElse"; // outputs Something 
         //   Else 
+0

你在開玩笑吧!謝謝!對於直接在PHP中定義的字符串, ,但現在我使用GET通過更改URL設置文本, $ quotes = $ _GET [「msg」]; URL image.php?味精=東西\ nElse 結果\\ N(兩個斜槓的前N) 你知道爲什麼會這樣? 「味精」是在雙引號,所以它不應該工作? – mattneedshelp 2012-03-29 12:32:25