PHP heredoc Problems

Jump to First Reply
Posted:
in Genius Bar edited January 2014
Except for the echo line, that is from the example on the PHP.net website. I do not want to have to add escape characters to all my stuff and would like to know why I get the error:



Parse error: parse error in /Library/WebServer/Documents/TMPhy0f8o14id.php on line 4



Is there something I have to change in the php.ini file or why-o-why doesn't this work?



Code:


<?php

$str = <<<EOD

Example of string

spanning multiple lines

using heredoc syntax.

EOD;

echo($str);

?>



Comments

  • Reply 1 of 2
    I just tried this in OS X 10.2.8 with PHP4 and it worked for me. I didn't have to change anything in my ini file.



    Are you using a text editor to create the file? You have to make sure that there are valid CrLf line ends in the file. If you're not using a text editor I bet that its not putting the proper line ends in.



    I used VI to create the php file.
     0Likes 0Dislikes 0Informatives
  • Reply 2 of 2
    ast3r3xast3r3x Posts: 5,012member
    Using Dreamweaver. PHP 4.3.4 with the Liyanage build I got from entropy.ch.



    It's very annoying.



    Edit: Ok seems to be dreamweaver. I saved two exact files (other then the filename) from dreamweaver and subethaedit and subethaedit worked.
     0Likes 0Dislikes 0Informatives
Sign In or Register to comment.