2013-03-21 66 views
-2

我在我的文件中有這行代碼,但在返回數組部分中,我需要在數組內部使用雙引號。陣列中的雙引號

如果我現在離開它,它會崩潰。

我該如何解決這個問題?

if ($number_of_picture_allowed <= $number_of_picture) 
     return array('error' => "{tr domain="PhrasesInTemplates"}You already selected the maximum amount of pictures for this shirt!{/tr}",'file_sid' => $fileSid); 

謝謝advace, Arky

+2

您是否閱讀過有關[字符串](http://php.net/manual/en/language.types.string.php)的文檔? – sectus 2013-03-21 10:12:01

+0

謝謝,我認爲這是關於Smarty語法的東西..我的壞。 – Arkymedes 2013-03-21 10:30:03

回答

1

逃生使用反斜槓(\)這些報價逃脫陣列引號內。因此,你的回報應該是:

return array('error' => "{tr domain=\"PhrasesInTemplates\"}You already selected the maximum amount of pictures for this shirt!{/tr}",'file_sid' => $fileSid); 
1

可以使用\

return array('error' => "{tr domain=\"PhrasesInTemplates\"}You already selected the maximum amount of pictures for this shirt!{/tr}",'file_sid' => $fileSid); 
0

試試這個:

  1. 裹在單引號中的內容使用反斜線(\)\」

$arr = array('error' => '{tr domain="PhrasesInTemplates"}You already selected the maximum amount of pictures for this shirt!{/tr}','file_sid' => $fileSid);

  • 逃生報價

  • 1
    if ($number_of_picture_allowed <= $number_of_picture) 
        return array('error' => "{tr domain=\"PhrasesInTemplates\"}You already selected the maximum amount of pictures for this shirt!{/tr}",'file_sid' => $fileSid); 
    

    試試這個。 PHP Double Quotes