Jump to content


Photo

nl2br help, where to use?


  • Please log in to reply
4 replies to this topic

#1 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 31 August 2006 - 07:36 AM

Hi there, I'm trying to use nl2br to force text to a next line, how do I use it in this instance though?

<?=$row['location']?>

I tried with no luck this:

<?=nl2br($row['location'])?>

Thanks.



~ Mutley.

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 31 August 2006 - 07:41 AM

Instead of using the short way "<?=", try using echo().

<?php
echo(nl2br($row['location']));
?>

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 31 August 2006 - 07:43 AM

You should generally always use <?php instead of <?, at least if you are going to publish it, since you can't except that all users support the latter one.

#4 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 31 August 2006 - 07:56 AM

echo is language construct, not a function, thus you shouldn't use parenthesis.
<?php

echo nl2br($row['location']);

?>


#5 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 31 August 2006 - 08:24 AM

I find it more comfortable to use parenthesis, and there is nothing wrong with doing that...

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users