Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP INLCUDE

Status
Not open for further replies.

SRW11

MIS
Joined
Mar 1, 2002
Messages
2
Location
US
I am trying to include a php file in my website.
But it seems that when you include the file you cannot pass variables at the same time.

i need to include a file and pass avariable to that file to get a perticular color for my table.

Can anybody help???

>V.php
<?php include(&quot;file.php?color=#00FF00&quot;);
?>

//writes the variable which is a table
<?=$table>

//gets the variable value and inputs it in the code and sends the new value of $table to the v.php

>file.php
<?php $table = '<table color=&quot;';.$color.'&quot;><td><tr></tr></td></table>';
?>
 
I haven't had any problems doing this by simply putting the variable assignment before the include().

Ex:
$color = #FFFFFF;
include('filegetscolor.php');

Any reference to $color in 'filegetscolor.php' should inherit the value you assigned before the include.
Matt
matt@paperlove.org
If I can help, I will.
 
when you use
<?php
require(&quot;file.php?color=#00FF00&quot;);
?>
does it do the same thing?
) =================================
Imagination is more important than knowledge.
(A.E.)
 
Thanks

puting the variables infront works!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top