Re: define ('NL', "<br />"); can I define a constant var ? [message #180188 is a reply to message #180184] |
Wed, 23 January 2013 00:50 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 1/22/2013 5:51 PM, Jørn Andersen wrote:
> On Tue, 22 Jan 2013 09:39:07 +0100, Arno Welzel <usenet(at)arnowelzel(dot)de>
> wrote:
>
>> With variables this would be easier though:
>>
>> $NL = '<br />';
>> echo "This is $NL another line";
>
> A question from someone relatively new to PHP:
> Why use constants at all?
> I always use variables - have I missed something?
>
> Best,
> Jørn, Copenhagen
>
Actually, a more correct answer would be the same reason you use
constants in any language. They can't be changed.
You can get some very hard to find problems when something which is
supposed to be a constant gets the wrong value.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|