Re: define ('NL', "<br />"); can I define a constant var ? [message #180176 is a reply to message #180175] |
Tue, 22 January 2013 02:16 |
r.mariotti
Messages: 17 Registered: December 2011
Karma:
|
Junior Member |
|
|
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";
|
|
|