ShadowPaktu Posted September 26, 2004 Posted September 26, 2004 I'm getting into php alot now, particually with my forums, i experiemtn alot, but ive never needed to include files. This dawned on me as it would be so much easier to update my site (not the forums) but changing one file, it would take effect on all pages that it has included. Am i correct in that just after the <body> tag in the page where i want to load up a php file i put in <? include('filename.php'); ?> and then where i want a variable (provided i have a varibale defined in my php file) i just place $variablename where i want it to go? What if the variable is a color (which is what im first testing it on) <body text="#ffffff"> my text, ya i know there's not much formatting and htis will be in white </body> would that become: <body text="$variablename"> my text, ya i know there's not much formatting and htis will be in white </body> and the php file would be something like: <? $variablename ="#ffffff"; ?> i know there's somethign wrong with this cos it dont work! so any help to get me off to a start would be greatly appreciated.!!! Quote Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted September 26, 2004 Posted September 26, 2004 So, you have a variable in the include file? I don't quite get what you are asking... Quote Share this post Link to post Share on other sites More sharing options...
Bosco Posted September 26, 2004 Posted September 26, 2004 I'm getting into php alot now, particually with my forums, i experiemtn alot, but ive never needed to include files. This dawned on me as it would be so much easier to update my site (not the forums) but changing one file, it would take effect on all pages that it has included. Am i correct in that just after the tag in the page where i want to load up a php file i put in include('filename.php'); ?> and then where i want a variable (provided i have a varibale defined in my php file) i just place $variablename where i want it to go? What if the variable is a color (which is what im first testing it on) my text, ya i know there's not much formatting and htis will be in white would that become: my text, ya i know there's not much formatting and htis will be in white and the php file would be something like: $variablename ="#ffffff"; ?> i know there's somethign wrong with this cos it dont work! so any help to get me off to a start would be greatly appreciated.!!! Your body tag must read something like: When you are just using: You are not parsing $variablename through PHP. Quote Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted September 26, 2004 Posted September 26, 2004 Not unless the <body text="$blah"> is in an echo or whatever Quote Share this post Link to post Share on other sites More sharing options...
ShadowPaktu Posted September 26, 2004 Posted September 26, 2004 Ah, i sorted it know, i created a test page to get it working and currently my main page which calls 2 others, looks like this: <?php $pagetitle = "Shadow is testin PHP!!!"; require ("header.php"); require ("game1.php"); require ("game2.php"); require ("footer.php"); ?> one of my other called php's looks like this, the header.php: <html> <head> <title> <?php print ("PageTitle"); ?> </title> </head> <body bgcolor="#f1f1f1"> the end body tag is finnished in the footer php file. What i want to know is how to assign values still like text color=$textcolor where $textcolor = "#ffffff" in a php file called 'colors.php' so if i want to update the text color of all my pages, instead of going through each one and changeing them, i would just open up the colors.php and change it there. As all my HTML pages use the 'text color' as what ever is in the 'colors.php' they would all call it. Quote Share this post Link to post Share on other sites More sharing options...
galla2k4eva Posted October 2, 2004 Posted October 2, 2004 whats wrong with css for changing the colours. i love working with php but i would definately use css for the text colours and backround colours Quote Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted October 2, 2004 Posted October 2, 2004 <body bgcolor="#f1f1f1"> would be <body bgcolor="<?php echo $textColour;?>"> Quote Share this post Link to post Share on other sites More sharing options...
OvKillz Posted October 2, 2004 Posted October 2, 2004 Why dont you jsut do a .css instead? Quote Share this post Link to post Share on other sites More sharing options...
galla2k4eva Posted October 2, 2004 Posted October 2, 2004 Why dont you jsut do a .css instead? thats what i was trying to say Quote Share this post Link to post Share on other sites More sharing options...
ShadowPaktu Posted October 2, 2004 Posted October 2, 2004 one small point on that... how? lol, i havn;t worked with css before, only with php comes close to what css would be doing. Quote Share this post Link to post 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.