On Wed, Dec 14, 2011 at 4:59 AM, Rick Dwyer <rpdw...@earthlink.net> wrote:

> 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>";

On Wed, Dec 14, 2011 at 9:09 AM, Peter Ford <p...@justcroft.com> wrote:

> Horses for courses. I use whatever I feel like at the time, and mix
> various styles, as long as it's readable!

I agree with Peter here. I would bet that the string with embedded
variables is parsed once when the file is loaded and turned into the same
bytecode as the second form.

If you are going to use the second style above, I would at least switch the
quotes around so you can use the double-quotes in the HTML as that to me
reads nicer and avoids the minor cost of scanning the string for embedded
code. I also put spaces around the dots to make the variable concatenation
easier to spot when skimming it.

    echo '<a style="text-align:left;size:**14;font-weight:bold"
href="/mypage.php/' . $page_id . '">' . $page_name . '</a><br>';


Reply via email to