Log in

View Full Version : php and css



stevedc
06-18-2008, 09:52 PM
Hi all,

I'm relatively new to PHP and was wondering something. If I create a header, footer or nav bar that is a div, should the div be applied in the .php include file (i.e. - footer.php) or should the div be placed in the home page or template page and just bring in the text or images. So I guess I wondering if their is a proper way to apply php to css and visa versa. It seems like it would be easiest to layout the page / divs where I want them and then place include files with information inside of their respective div. I just didn't know what standard practices are...Sorry, but most of my sites have either been css/html or flash and even something as simple as a server side include is new to me.

Jas
06-20-2008, 06:18 PM
I'm not sure that I understand, but usually as far as pulling in information goes, you would do something like this:


<?php
include('file.php');

echo <<< END
<html>
<head>
<title>$title</title>
</head>
<body>
<div>$body</div>
</body>
</html>
END;

?>

But you can also do this:


<?php
$title = '<title>Hello</title>';
$body = '<div>Hello</div>';

echo <<< END
<html>
<head>
$title
</head>
<body>
$body
</body>
</html>
END;

?>

It mostly depends on how you are creating the page. The best way, I would say, is to put as much as you can in the main template and as little as you can in the vars or other files.