ok, I think it's time for a little rollback before you destroy your script ceompletely because of our
help
After I started following your suggestions along with evilcoder's, I started getting the output displayed on the page instead of it being used as an attribute for the <body> tag.
that's right.mark my
edit: oops, you want to write properties. forget about the <body></body> but do enable error_reporting/displaying
so my suggestion was
Code: Select all
<BODY <?php error_reporting(E_ALL); ini_set('display_errors', TRUE); include("include.php"); ?> >
to enable the error output. since it would happen withing the body-tag the rendered result (note the difference between script-output and rendered result within the client/browser) might be broken and you had to open the browser's source view (where you can see the script's output).
now for evilcoder's suggestion
evilcoder wrote:<?php
$bodyvars = include( "filewithechoinit.php" );
?>
<body <?=$bodyvars ?> >
it includes
and executes filewithechoinit.php, so anything that is echoed in
filewithechoinit.php will be added to the output stream. $bodyvars would fetch a global scope return value of
filewithechoinit.php, but there isn't any. So the output of
filewithechoinit.php (
PHP/PHP_Body_Tag.php in your case) will take place before the <body>-tag and <?=$bodyvars ?> might be executed (
if short-tags are enabled) but print nothing (in the worst case it would print
1, which you might check in the browser's source view)
css seperates the layout from the contents, e.g. try
Code: Select all
<html>
<head>
<style type="text/css">
body { background-color: white; color: black; }
p { background-color: silver; }
p.redbg { background-color: red; }
a { color: #B9B9B9 }
a:hover { color: green }
</style>
</head>
<body>
<a name="anchor1" ></a>
<p>bla bla bla</p>
<a name="anchor2" ></a>
<p class="redbg">bla bla bla</p>
<a href="#anchor1">goto anchor #1</a>
<a href="#anchor2">goto anchor #2</a>
<a href="javascript:void()">do nothing</a>
</body>
</html>
but the stylesettings are still within the page. You can write them to a different file and let the browser include it.
stylesA.css:
Code: Select all
body { background-color: white; color: black; }
p { background-color: silver; }
p.redbg { background-color: red; }
a { color: #B9B9B9 }
a:hover { color: green }
index.html:
Code: Select all
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesA.css">
</head>
<body>
<a name="anchor1" ></a>
<p>bla bla bla</p>
<a name="anchor2" ></a>
<p class="redbg">bla bla bla</p>
<a href="#anchor1">goto anchor #1</a>
<a href="#anchor2">goto anchor #2</a>
<a href="javascript:void()">do nothing</a>
</body>
</html>
if you define different stlyes in different files all your php script has to do is to write the url to the href-property of the link-element
Code: Select all
<?php $urlCSS = 'stylesA.cc'; // or somthing more complex ?><html>
<head>
<link rel="stylesheet" type="text/css" href="<?php echo $urlCSS; ?>">
</head>
<body>
<a name="anchor1" ></a>
<p>bla bla bla</p>
<a name="anchor2" ></a>
<p class="redbg">bla bla bla</p>
<a href="#anchor1">goto anchor #1</a>
<a href="#anchor2">goto anchor #2</a>
<a href="javascript:void()">do nothing</a>
</body>
</html>