tomfmason Posted June 30, 2006 Share Posted June 30, 2006 I have a main php file that has three columns with header and footer. The content is the only thing that will change from page to page. I am wondering how I can give the content a variable name and print it into the main. phphere is the main.php[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><!-- DW6 --><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>The Home of Owpt</title><link rel="stylesheet" href="main.css" type="text/css"></head><body bgcolor="#707070"><div id="master"> <div id="masthead"> <?php include("header.php"); ?> </div> <div id="navBar"> <?php include("navbar.php"); ?> </div> <!--end navBar div --> <div id="headlines"> <?php include("headlines.php"); ?> </div> <!--end headlines --> <div id="content"> <?php print('$content'); ?> </div> <!--end content --> <div id="siteInfo"> <?php include("footer.php"); ?> </div></div> <br> </body></html>[/code] and here is the content for the main page[code]<?php include("includes/main.php"); $content = "<div class="feature"> <img src="images/php.jpg" alt="" width="160" height="120"> <p> <b>Look Ma No Tables</b> </p> <p> This is a test page that is made entirely of css layouts. </p> <p> I am knew to web design. I know that this is a very simple layout but it is my first. </p> <p> So Back Off....LOL </p> </div> <div class="story"> <h3>Goals</h3> <p> My main goals are to learn html/xhtml, css, php. I will be posting tutorials based on my experience. One of the first tutorials that I will be creating is a step by step instruction on developing css based layouts. This means that I must learn more about it first...lol </p> </div> <div class="story"> <h3>Problems</h3> <p> I have several problems the first being the layout of my columns. </p> <p> <------------------------------------------------------------------------------------------------> </p> <p> I would like the right, left and center columns lengths to be the same as the longest of the three. There are many more but I will try to figure them out my self. </p> </div>"?> [/code]I know that I can use echo but I don't think that that is the proper way to do it. Any suggestions would be great. Quote Link to comment https://forums.phpfreaks.com/topic/13283-printing-html/ Share on other sites More sharing options...
zq29 Posted June 30, 2006 Share Posted June 30, 2006 It's perfectly fine to use echo, although you must be careful with your quotes, you must escape double quotes if your text is enclosed in double quotes, or replace them with single quotes.[code]<?php//This is correctecho "Hello, my name is 'Kris', pleased to meet you.";//This is also correctecho "Hello, my name is \"Kris\", pleased to meet you.";//This is incorrectecho "Hello, my name is "Kris", pleased to meet you.";?>[/code]An alternative would be to use the HEREDOC syntax, you can see how to use it [url=http://uk.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc]here in the manual[/url]. Quote Link to comment https://forums.phpfreaks.com/topic/13283-printing-html/#findComment-51167 Share on other sites More sharing options...
tomfmason Posted June 30, 2006 Author Share Posted June 30, 2006 I fixed the syntax errors...ie the double quotes. I also included the main.php in the beging of the content page instead of at the end. I made this a lot more complacated then it needed to be...lolThe fix to the content page:[code]<?php $title = "The Home Of Owpt"; $content = " <div class=\"feature\"> <img src=\"images/php.jpg\" alt=\"\" width=\"160\" height=\"120\"> <p> <b>Look Ma No Tables</b> </p> <p> This is a test page that is made entirely of css. </p> <p> I am knew to web design. I know that this is a very simple layout but it is my first. </p> <p> So Back Off....LOL </p> </div> <div class=\"story\"> <h3>Goals</h3> <p> My main goals are to learn html/xhtml, css, php. I will be posting tutorials based on my experience. One of the first tutorials that I will be creating is a step by step instruction on developing css based layouts. This means that I must learn more about it first...lol </p> </div> <div class=\"story\"> <h3>Problems</h3> <p> I have several problems the first being the layout of my columns. </p> <p> <------------------------------------------------------------------------------------------------> </p> <p> I would like the right, left and center columns lengths to be the same as the longest of the three. There are many more but I will try to figure them out my self. </p> </div>" ?><?php include("includes/main.php"); ?>[/code]Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/13283-printing-html/#findComment-51236 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.