FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » define ('NL', "<br />"); can I define a constant var ?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: define ('NL', "<br />"); can I define a constant var ? [message #180177 is a reply to message #180176] Tue, 22 January 2013 02:50 Go to previous messageGo to previous message
Kim Andr Aker is currently offline  Kim Andr Aker
Messages: 17
Registered: September 2010
Karma:
Junior Member
På Tue, 22 Jan 2013 03:16:28 +0100, skrev BobMCT <r(dot)mariotti(at)fdcx(dot)net>:

> On Tue, 22 Jan 2013 00:44:49 +0000 (UTC), Adam Harvey
> <usenet(at)adamharvey(dot)name> wrote:
>
>> On Mon, 21 Jan 2013 16:06:46 -0800, cate wrote:
>>> I can see why this doesn't work:
>>>
>>> define ('NL', '<br />');
>>> echo "This is NL another line";
>>>
>>> Is there a way to define a constant variable in PHP?
>>
>> Not as such — you can define constants with define() or (in 5..3.0+) the
>> const keyword, but they aren't variables and hence aren't interpolated
>> into strings, as you've discovered.
>>
>> As an alternative, there's always:
>> echo "This is ".NL." another line";
>>
>> Adam
>
>
> Or perhaps an easier string approach:
>
> echo "this is \n another line";

Alternatively:

echo nl2br("This is \n another line");

http://php.net/nl2br


--
Kim André Akerø
- kimandre(at)NOSPAMbetadome(dot)com
(remove NOSPAM to contact me directly)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Passing complex data back when using cURL
Next Topic: my blog
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 14:04:35 GMT 2024

Total time taken to generate the page: 0.05014 seconds