Hey Martin.
I'm a little confused by this, because it's called "header" but there isn't any
html markup. Don't you want the initial javascript reference in the <head>? Maybe not, this really just looks like a table you want to insert at some point.
Hmm, I'm thinking maybe you want this include in the body but can't figure out how to get the javascript reference in the <head> section? If so, you need to echo a variable $showtable in the
<head> section of the page.
- Code: Select all
<html><head><?php echo $showtable; ?> . . . </head>
Then set the variable in the
include file, like
- Code: Select all
$showtable = '<script type="text/javascript" src="flashobject.js"></script>';
The only kicker is that the include will have to occur higher on the page than the <head> so that the variable is defined before it is echoed.
I can't comment on the functionality of the code, but I have a couple of technique hints. There's nothing wrong with what you have, I just thought you might want to see a couple of other ways to do it.
- Code: Select all
{echo "<p class=\"filename\">This file is: " . $thisfile . "</p>";}
First off, you don't need the curly brackets if you only have one result from an "if" condition.
i- Code: Select all
if(SHOWFILENAMES == "on") echo "<p class=\"filename\">This file is: " . $thisfile . "</p>";
If you use
php to echo
html markup, the "heredoc" statement is handy for long passages. What you already have might be better but I just thought I'd show it to you if you don't know about it.
- Code: Select all
if (SHOWFILENAMES == "on")
$s= <<<EOD
<p class="filename">This file is: $thisfile</p>
EOD
echo $s;
No markup, no escapes, no concats.
Once you bother doing all the escaping work to have a passage in double quotes, there's no need to worry about concats (and vice versa). You're doing double effort.
Either
- Code: Select all
echo '<p class="filename">This file is: ' . $thisfile . '</p>';
or
- Code: Select all
echo "<p class=\"filename\">This file is: $thisfile</p>";
Like you, I'm learning
php. I've been studying a little every day, for a few months. It's like the Hydra: everytime you cut off one head, two grow back. It's been a big help to me to do nothing but study for a bit every day. Currently I'm working my way through O'Reilly's "Programming
PHP" and a really good (free!) online tutorial about regular expressions at
http://www.regular-expressions.info/php.html
I hope these hints are helpful (and correct, LOL).