Jump to content

using php include function and divs


Digitry Designs

Recommended Posts

Ok so I am experimenting with a lil sum sum right now. I need to find out if I need to use html or php to do what I want. I am trying to make a site extremely simple in all of its complexities.

 

simple tree

 

index.php

    |

    |______________________________________________

                  |                                                                            |

            INCLUDE                                                                TEMPLATE/CSS

                  |                                                                            |

                  |-home.php                                                            |-main.css

                  |-header.php                                                          |-header.css

                  |-menu.php                                                            |-menu.css

                  |-login.php                                                              |-login.css

                  |-content.php                                                        |-content.css

                  |sidebar.php                                                          |-sidebar.css

                  |footer.php                                                            |-footer.css

 

on index.php here is what i have right now.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php 
//include_once("include/analyticstracking.php") 
?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

	<title>Web Design and Development</title>

	<link href="template/css/main.css" rel="stylesheet" type="text/css" />
	<link href="template/css/header.css" rel="stylesheet" type="text/css" />
	<link href="template/css/login.css" rel="stylesheet" type="text/css" />
	<link href="template/css/menu.css" rel="stylesheet" type="text/css" />
	<link href="template/css/content.css" rel="stylesheet" type="text/css" />
	<link href="template/css/sidebar.css" rel="stylesheet" type="text/css" />
	<link href="template/css/footer.css" rel="stylesheet" type="text/css" />
	<link href="template/css/flash.css" rel="stylesheet" type="text/css" />

</head>



<body>

	<div id="container">

		<?php 

			include_once("include/header.php");
			include_once("include/menu.php");
			include_once("include/content.php");
			include_once("include/login.php");
			include_once("include/sidebar.php");
			include_once("include/footer.php");

		?>

	</div>

</body>

</html>

 

then on say header.php i used concatination and have this

 

<?php

echo "<div id='header'>" .

"</div>";

?>

 

would this actually work using the main page to call up the css files then using php to include the file the uses that css file?

Link to comment
https://forums.phpfreaks.com/topic/199699-using-php-include-function-and-divs/
Share on other sites

Since includes just add to your code as if they were the same file, it will work accordingly. Although I'll note that you don't need to use echo in header.php or others. For example header.php could just be

 

 

<div id="header">

 

</div>

 

 

Without any PHP tags or echos.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.