From: chris h on
On Tue, Oct 5, 2010 at 3:58 PM, Steve Staples <sstaples(a)mnsi.net> wrote:

> On Tue, 2010-10-05 at 20:53 +0100, Ashley Sheridan wrote:
> > On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
> >
> > > On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
> > > > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
> > > >
> > > > > Benchmark and find out! :)
> > > > >
> > > > > What are you using this for? Unless you are doing something crazy
> it
> > > > > probably doesn't matter, and you should pick whichever you feel
> looks nicer
> > > > > / is easier to code in / etc.
> > > > >
> > > > > Chris H.
> > > > >
> > > > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed <saeed.sas(a)gmail.com>
> wrote:
> > > > >
> > > > > > $a = 'hey';
> > > > > > $b = 'done';
> > > > > >
> > > > > > $c = $a.$b;
> > > > > > $c = "$a$b";
> > > > > >
> > > > > > which one is faster for echo $c.
> > > > > >
> > > >
> > > >
> > > > As far as I'm aware, the first of the two will be faster, but only
> just.
> > > > As Saeed mentioned, the difference will be negligible, and unless you
> > > > plan to run a line like that in a loop or something hundreds of
> > > > thousands of times, you probably won't notice any difference.
> > > > Thanks,
> > > > Ash
> > > > http://www.ashleysheridan.co.uk
> > > >
> > > >
> > >
> > >
> > > to be proper, shouldn't it technically be
> > > $c = "{$a}{$b}";
> > >
> > > ??
> > >
> > > Steve.
> > >
> > >
> >
> >
> > It doesn't have to use the braces. The braces only tell PHP exactly
> > where to stop parsing the current variable name. The following examples
> > wouldn't work without them:
> >
> > $var = 'hello ';
> > $arr = array('msg 1'=>'hello','msg 2'=>'world');
> >
> > echo "{$var}world";
> > echo "{$arr['msg 1']}{$arr['msg 2']}";
> >
> > Without the braces, in the first example PHP would look for a variable
> > called $varworld, and in the second it would be looking for a simple
> > scaler called $arr, not the array value you wanted.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> Ash:
>
> I understand what the {} does, but just like in HTML, it is more proper
> to use lower case for the attributes/elements, and use " (double quotes)
> when wrapping the attributes... but is it not "REQUIRED" to write it in
> that manner... just like it is not required to wrap the variables in {}
> when inside the ""...
>
> that's just me, I tend to try and do that every time...
>
> Steve.
>
>

Unlike HTML, PHP interpretation doesn't have various browsers to contend
with. And even if it was not proper I have a doubt that not using {} would
become deprecated anytime soon.

Also laziness is a trait of a good programmer! :)
http://c2.com/cgi/wiki?LazinessImpatienceHubris

Chris H.
From: "Jo�o C�ndido de Souza Neto" on
As I can see, it�d be too much faster to decide by yourself than reading all
theese answers and understanding their differences and taking people�s time
for nothing.

--
Jo�o C�ndido de Souza Neto

"saeed ahmed" <saeed.sas(a)gmail.com> escreveu na mensagem
news:AANLkTikh6g5iLSz3HKxaTg=H1wzoBGoKo7bYNGo0pOdy(a)mail.gmail.com...
> $a = 'hey';
> $b = 'done';
>
> $c = $a.$b;
> $c = "$a$b";
>
> which one is faster for echo $c.
>


From: "Bob McConnell" on
From: Steve Staples

> On Tue, 2010-10-05 at 20:53 +0100, Ashley Sheridan wrote:
>> On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
>>
>> > On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
>> > > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
>> > >
>> > > > Benchmark and find out! :)
>> > > >
>> > > > What are you using this for? Unless you are doing something
crazy it
>> > > > probably doesn't matter, and you should pick whichever you feel
looks nicer
>> > > > / is easier to code in / etc.
>> > > >
>> > > > Chris H.
>> > > >
>> > > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed
<saeed.sas(a)gmail.com> wrote:
>> > > >
>> > > > > $a = 'hey';
>> > > > > $b = 'done';
>> > > > >
>> > > > > $c = $a.$b;
>> > > > > $c = "$a$b";
>> > > > >
>> > > > > which one is faster for echo $c.
>> > > > >
>> > >
>> > >
>> > > As far as I'm aware, the first of the two will be faster, but
only just.
>> > > As Saeed mentioned, the difference will be negligible, and unless
you
>> > > plan to run a line like that in a loop or something hundreds of
>> > > thousands of times, you probably won't notice any difference.
>> > > Thanks,
>> > > Ash
>> > > http://www.ashleysheridan.co.uk
>> >
>> > to be proper, shouldn't it technically be
>> > $c = "{$a}{$b}";
>> >
>>
>> It doesn't have to use the braces. The braces only tell PHP exactly
>> where to stop parsing the current variable name. The following
examples
>> wouldn't work without them:
>>
>> $var = 'hello ';
>> $arr = array('msg 1'=>'hello','msg 2'=>'world');
>>
>> echo "{$var}world";
>> echo "{$arr['msg 1']}{$arr['msg 2']}";
>>
>> Without the braces, in the first example PHP would look for a
variable
>> called $varworld, and in the second it would be looking for a simple
>> scaler called $arr, not the array value you wanted.
>>
> Ash:
>
> I understand what the {} does, but just like in HTML, it is more
proper
> to use lower case for the attributes/elements, and use " (double
quotes)
> when wrapping the attributes... but is it not "REQUIRED" to write it
in
> that manner... just like it is not required to wrap the variables in
{}
> when inside the ""...
>
> that's just me, I tend to try and do that every time...

XHTML requires both lower case and double quotes. So if that may be in
your future, you should be using both already.

I don't know about HTML 5. Since that spec is still years away from
completion and hasn't added anything we can make use of, we haven't even
bothered to look at it.

Bob McConnell
From: Peter Lind on
On 6 October 2010 14:40, Bob McConnell <rvm(a)cbord.com> wrote:
> From: Steve Staples
>
>> On Tue, 2010-10-05 at 20:53 +0100, Ashley Sheridan wrote:
>>> On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
>>>
>>> > On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
>>> > > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
>>> > >
>>> > > > Benchmark and find out! :)
>>> > > >
>>> > > > What are you using this for? Unless you are doing something
> crazy it
>>> > > > probably doesn't matter, and you should pick whichever you feel
> looks nicer
>>> > > > / is easier to code in / etc.
>>> > > >
>>> > > > Chris H.
>>> > > >
>>> > > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed
> <saeed.sas(a)gmail.com> wrote:
>>> > > >
>>> > > > > $a = 'hey';
>>> > > > > $b = 'done';
>>> > > > >
>>> > > > > $c = $a.$b;
>>> > > > > $c = "$a$b";
>>> > > > >
>>> > > > > which one is faster for echo $c.
>>> > > > >
>>> > >
>>> > >
>>> > > As far as I'm aware, the first of the two will be faster, but
> only just.
>>> > > As Saeed mentioned, the difference will be negligible, and unless
> you
>>> > > plan to run a line like that in a loop or something hundreds of
>>> > > thousands of times, you probably won't notice any difference.
>>> > > Thanks,
>>> > > Ash
>>> > > http://www.ashleysheridan.co.uk
>>> >
>>> > to be proper, shouldn't it technically be
>>> > $c = "{$a}{$b}";
>>> >
>>>
>>> It doesn't have to use the braces. The braces only tell PHP exactly
>>> where to stop parsing the current variable name. The following
> examples
>>> wouldn't work without them:
>>>
>>> $var = 'hello ';
>>> $arr = array('msg 1'=>'hello','msg 2'=>'world');
>>>
>>> echo "{$var}world";
>>> echo "{$arr['msg 1']}{$arr['msg 2']}";
>>>
>>> Without the braces, in the first example PHP would look for a
> variable
>>> called $varworld, and in the second it would be looking for a simple
>>> scaler called $arr, not the array value you wanted.
>>>
>> Ash:
>>
>> I understand what the {} does, but just like in HTML, it is more
> proper
>> to use lower case for the attributes/elements, and use " (double
> quotes)
>> when wrapping the attributes... but is it not "REQUIRED" to write it
> in
>> that manner... just like it is not required to wrap the variables in
> {}
>> when inside the ""...
>>
>> that's just me, I tend to try and do that every time...
>
> XHTML requires both lower case and double quotes. So if that may be in
> your future, you should be using both already.
>
> I don't know about HTML 5. Since that spec is still years away from
> completion and hasn't added anything we can make use of, we haven't even
> bothered to look at it.
>

Where exactly do you get the part about double quotes from? Can't seem
to locate it in the any of the relevant specs (xhtml or xml). Also,
never seen an xml or xhtml validator choke on single quotes.

As for html 5, it's in use today already. Big parts of it are unlikely
to change, so there's little reason not to start using it.

Regards
Peter

--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
From: Robert Cummings on
On 10-10-06 08:52 AM, Peter Lind wrote:
> Where exactly do you get the part about double quotes from? Can't seem
> to locate it in the any of the relevant specs (xhtml or xml). Also,
> never seen an xml or xhtml validator choke on single quotes.

http://www.w3.org/TR/xhtml1/#h-4.2

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: i wanna join
Next: Variable (Class instantiation) collision