RE: Preferred Syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Adam Richardson [mailto:simpleshot@xxxxxxxxx]
> Sent: Wednesday, December 14, 2011 2:19 PM
> To: Rick Dwyer
> Cc: PHP-General
> Subject: Re:  Preferred Syntax
> 
> On Wed, Dec 14, 2011 at 7:59 AM, Rick Dwyer <rpdwyer@xxxxxxxxxxxxx>
> wrote:
> 
> > Hello all.
> >
> > Can someone tell me which of the following is preferred and why?
> >
> >  echo "<a style='text-align:left;size:**14;font-weight:bold'
> > href='/mypage.php/$page_id'>$**page_name</a><br>";
> >
> >  echo "<a style='text-align:left;size:**14;font-weight:bold'
> > href='/mypage.php/".$page_id."**'>".$page_name."</a><br>";
> >
> > When I come across the above code in line 1, I have been changing it
> to
> > what you see in line 2 for no other reason than it delineates out
> better in
> > BBEdit.  Is this just a preference choice or is one method better
> than the
> > other?
> >
> 
> I prefer sending arguments to the echo language construct (note, if you
> send more than one argument, you can't use parentheses.) I perceive
> this
> usage to be a clean presentation of the code's intent, easy to use in
> most
> IDE's, and it's very fast relative to the other options:
> 
> echo "<a style='text-align:left;size:**14;font-weight:bold'
> href='/mypage.php/$page_id'>$**page_name</a><br>";
> 
> echo "<a style='text-align:left;size:**14;font-weight:bold'
> href='/mypage.php/".$page_id."**'>".$page_name."</a><br>";
> 
> echo "<a style='text-align:left;size:**14;font-weight:bold'
> href='/mypage.php/", $page_id, "'>", $**page_name, "</a><br>";
> 
> And, for longer lines, I'll often break it up into separate lines by
> argument like below:
> 
> echo
>     "<a style='text-align:left;size:**14;font-weight:bold'
> href='/mypage.php/",
>     $page_id,
>     "'>",
>     $**page_name,
>     "</a><br>";
> 
> That all said, I don't change code that uses another convention, as I
> think
> it's most beneficial to stay with the established conventions in any
> codebase (unless you're establishing a new convention and refactoring
> the
> entire code base.) This is just my general preference, and I don't
> believe
> there is consensus as to the most appropriate.
> 
> Adam
> 
> --
> Nephtali:  A simple, flexible, fast, and security-focused PHP framework
> http://nephtaliproject.com



Adam,
	You are very correct, the last discussions and testing of theories
caused my head to hurt!!! 
Neither side gained ground in testing or discussion.
Having said that to me it is a preference only and not a performance
enhancing or degrading factor in syntax.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux