Will a suggestion in this article about PHP put browsers into quirks mode?

P

patrick j

Hi

I'm just exploring the world of PHP and very interesting it is too :)

Anyway the thing which has interested me initially is putting the
navigation section of the web-site into a separate file to be included in
all the other pages of the web-site.

Very cool is the fact that with some jiggerypokery with a variable I can
have the included navigation identify the "current" link.

This is all described rather well in this article here:

<http://alistapart.com/articles/keepingcurrent/>

However there is one thing which I'm wondering about which in this bit:

You¹ll need to add a unique identifier at the very top
of every page that PHP will understand, ideally
appearing before the HTML tag. You¹ll do this by
creating a variable called $thisPage and assigning a
value that is both descriptive and unique to the
document.

Okay, if I put my <?php $thisPage="Interesting Stuff"; ?> before the HTML
tag does this not put some browsers into quirks mode?

I'm wondering why the author feels it would be ideally located before the
HTML tag, surely it would only have to be in each page before the include
for the navigation section?

Thank you.
 
J

Jonathan N. Little

patrick said:
Okay, if I put my <?php $thisPage="Interesting Stuff"; ?> before the HTML
tag does this not put some browsers into quirks mode?

No, the browser does not even see it, there is no output. You are just
setting a variable on the *server*.
 
P

patrick j

No, the browser does not even see it, there is no output. You are just
setting a variable on the *server*.

A yes that makes a great deal of sense.

I am getting the hang of it gradually, honest :)
 
A

Adrienne Boswell

Gazing into my crystal ball I observed dorayme
So! A way to get rid of all the hand inserted class="current"s.
Excellent.

Yes, dear, and you can even make an array/function to do it. Just make
your array contain the page names and links, then while loop through
send the info to the function to see if $thispage is the current page,
and add your class. Easy peasy!
 
D

dorayme

Adrienne Boswell said:
Gazing into my crystal ball I observed dorayme


Yes, dear, and you can even make an array/function to do it. Just make
your array contain the page names and links, then while loop through
send the info to the function to see if $thispage is the current page,
and add your class. Easy peasy!

Like uneaten chocolates, all these wonderful things are there,
one only needs to open the lid and pick and choose.
 
A

Andy Dingley

A way to get rid of all the hand inserted class="current"s.

You can ditch almost all of those by adding a class="foo-section" to
the <body> and testing for equivalence to foo-section within the page,
rather than having to add class="current" to every location that needs
it. More complex CSS selectors in one file, rather than repeated
additions throughout the pages. Works with SSI too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top