On 20/09/2022 19:29, Olle Härstedt wrote:
Ya ok, this kills my idea. If heredoc was designed from start so that the delimiter would not be allowed at all in the text, then it would make sense. Weird that they did it like that, would be easy enough to come up with a unique delimiter so that it would not cause a problem... Obviously it can't be changed now without breaking backwards compatibility.
For what it's worth, the "they" in question are the authors of the early Unix shells in the 1970s - from a quick search, it seems like the Bourne shell was the first to implement "here document" syntax, sometime around 1979. As the name suggests, they were not for defining strings, but for entering entire text files embedded in a script or interactive shell session.
In that context, the original format is actually elegantly minimal: content is read one line at a time; if it exactly matches the delimiter, stop; else, add the line to the file buffer. No actual parsing is required.
Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php