Re: [PHP] Couple of beginner questions



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

Which is unlikely for a header tag, but I know this sort of format gets
used a lot by me and others, especially for setting alternate row styles
on tables (damn browsers and not supporting alternate rows!)

Ash

Ash:

Here's the alterative I would use:

<h1 class="<php echo($headerClass);?>"><php echo($whatever);?></h1>

Again, please forgive my use of echo().

The point being, wherever you want to insert a variable, then do it,
but leave html out of your code.

My "alternate row styles" solution is this:

http://webbytedd.com/b/color-rows/

Please note that no html is harmed in the making of this presentation. :-)

Cheers,

tedd

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
www.ashleysheridan.co.uk

.



Relevant Pages

  • Re: How do we get there from here?
    ... > then sub the whole of that generated markup into the template? ... layed out on the fly, a simple IMG tag, or even an entire HTML document. ... PHP scripting provides 10 times the features of both of these ... idea as tokens can eliminate a huge amount of maintance, ...
    (comp.databases.pick)
  • Re: query string passing woes........ help... please....
    ... |> | offer any help other than saying that my validation could be FAR more ... I'm a total newbie at php. ... The easiest way for you would be to make the html form called form.php ... $_SESSION array using the same names. ...
    (alt.php)
  • Re: HELP - Cant change Include Path
    ... Here is my php.ini path for the php.ini in both php and sql dirs: ... which did work on the remote linux server and sent me some mail ... Although my gmail acct picked the mail up as ... an attachment instead of as html - but gmail is really wierd about ...
    (comp.lang.php)
  • Re: How do we get there from here?
    ... server-side-scripted html. ... This is a simple example with very little php scripting. ... means that the version of the php pre-processor on your web server must ... >>> The browser never sees anything not sent to it by the script. ...
    (comp.databases.pick)
  • Re: PHP-Yes, HTML-No --- Why?
    ... Because the files, when downloaded, are called .php and have absolutely no php in them:) ... But the extension doesn't match the contents of the file. ... Surely a dynamic web server should appear exactly the same as a static one - all files that contain HTML when viewed should be called .html. ...
    (comp.lang.php)