Support Forums
PHP Multiline Strings - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: PHP Multiline Strings (/showthread.php?tid=2767)

Pages: 1 2


RE: PHP Multiline Strings - Spl3en - 11-18-2009

@FarOut :
You're entirely right. "proper" wasn't the right word, i would mean.. mh.. well, i don't have enought word to explain my opinion.
Write a variable on several lines, it confused me, i prefer write it only in one line, even if it's not really eye-friendly. But i guess that's not the same thing for everyone Tongue.

But you're right about \n, which does exactly the same job as chr(10). Smile
PHP Code:
<?php
//Output 10
echo ord("\n");
?>

Quote:Sorry, I kinda rambled there. In short, chr() should definitely not be used for implementing newlines within a string ;).
Well, in general it's true. "\n" is sometimes considerate as a string, and not a newline.
PHP Code:
<?php
// Output 10
echo ord("\n");
// Output 92
echo ord('\n');
?>
I don't like the type conversion, so, i prefer use chr(10).

Note that \n is more optimized than heredoc, for the time execution.

Well, it's always interesting to see different manners to do the same thing Smile