Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Multiline Strings
#11
@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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 785 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,293 10-10-2011, 01:00 PM
Last Post: Greyersting

Forum Jump:


Users browsing this thread: 1 Guest(s)