2015-07-02 75 views
-3

我的PHP有什麼問題,爲什麼heredoc無法正常工作。我收到一條錯誤消息。PHP-Heredoc:不工作?

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Test</title> 
    </head> 
    <body> 

     <?php 
      $text = <<< EOT 
      Line 1\n 
      Line2\n 
      Line3. 
      EOT; 

      echo $text; 
     ?> 


    </body> 
</html> 

回答

1

嘗試將您的結尾heredoc放在行首。如果您使用的是有縮進的IDE,請移除它們!你的結尾heredoc應該與你的結尾php標籤垂直在同一行(