Re: [PHP] Couple of beginner questions
- From: ash@xxxxxxxxxxxxxxxxxxxx (Ashley Sheridan)
- Date: Sun, 11 Jan 2009 15:36:09 +0000
On Sun, 2009-01-11 at 10:16 -0500, tedd wrote:
At 3:02 PM +0000 1/11/09, Ashley Sheridan wrote:I was thinking more along the lines of this:
On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:
At 1:49 PM +0000 1/11/09, Ashley Sheridan wrote:> >
>Unless it's something like this:> >?>
>
><?php
>echo "<h1 class=\"$headerClass\">$whatever</h1>";
>
Here's the alterative I would use:> <h1 class="<php echo($headerClass);?>"><php echo($whatever);?></h1>
I'm not wanting ti nitpick, but what if there were several attributes
you needed to populate from the PHP? I just find it easier on my eyes to
include HTML in the PHP string that's being output, but I can see the
definite merits for echoing out single parts that would only get in the
way of the HTML.
Ash:
Nitpick as much as you want -- we all have our level of accommodation.
To me, there usually is a clear demarcation between the different
languages, their scope, and best application. If I had to deal with
several attributes, such as shown here:
<h1 class="red header">Hello World</h1>
I would write it up like so:
$header_class = "red header";
$whatever = "Hello World";
<h1 class="<php echo($header_class);?>"><php echo($whatever);?></h1>
In my css, I would have
.red
{
color: #ff0000;
}
.header
{
font-size: 1.2em;
}
That would solve the problem of several attributes and keep php,
html, and css separate.
So handling numerous attributes would not be a problem for me.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
echo "<img src=\"$url\" alt=\"$alt\" title=\"$alt\" class=\"$imgclass
\"/>";
which looks like this otherwise:
<img src="<?php echo($url);?>" alt="<?php echo($alt);?>" title="<?php
echo($alt);?>" class="<?php echo($imgclass);?>"/>
Ash
www.ashleysheridan.co.uk
.
- Follow-Ups:
- Re: [PHP] Couple of beginner questions
- From: tedd
- Re: [PHP] Couple of beginner questions
- From: "Eric Butera"
- Re: [PHP] Couple of beginner questions
- References:
- Couple of beginner questions
- From: "Gary"
- Re: [PHP] Couple of beginner questions
- From: tedd
- Re: [PHP] Couple of beginner questions
- From: "Gary"
- Re: [PHP] Couple of beginner questions
- From: tedd
- Re: [PHP] Couple of beginner questions
- From: Paul M Foster
- Re: [PHP] Couple of beginner questions
- From: tedd
- Re: [PHP] Couple of beginner questions
- From: Ashley Sheridan
- Re: [PHP] Couple of beginner questions
- From: tedd
- Re: [PHP] Couple of beginner questions
- From: Ashley Sheridan
- Re: [PHP] Couple of beginner questions
- From: tedd
- Couple of beginner questions
- Prev by Date: Re: [PHP] Couple of beginner questions
- Next by Date: Re: [PHP] Couple of beginner questions
- Previous by thread: Re: [PHP] Couple of beginner questions
- Next by thread: Re: [PHP] Couple of beginner questions
- Index(es):
Relevant Pages
|