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 #180183 is a reply to message #180181] Tue, 22 January 2013 19:40 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
On 22/01/13 18:58, Tim Streater wrote:
> In article <6833t9-kme(dot)ln1(at)luuk(dot)invalid(dot)lan>, Luuk <luuk(at)invalid(dot)lan>
> wrote:
>
>> On 22-01-2013 09:39, Arno Welzel wrote:
>>> cate, 2013-01-22 01:06:
>
>>> With variables this would be easier though:
>>>
>>> $NL = '<br />';
>>> echo "This is $NL another line";
>>>
>>
>> Why do you use single quotes on the first line,
>> and double on the second?
>>
>> Why not simply use double-quotes everywhere.....
>>
>> $NL = "<br />";
>> echo "This is $NL another line";
>
> Because the interpreter has to do more work with the string:
>
> <http://php.net/manual/en/language.types.string.php>
>
> If you do:
>
> $NL = '<br />';
> echo 'This is ' . $NL . 'another line';
>
> then you avoid the double-quote altogether.
>
Or easier yet

printf("This is <BR>a new line");
Or
$NL="<BR>";
printf("This is %s a new line",$NL);

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
[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:11:51 GMT 2024

Total time taken to generate the page: 0.03807 seconds