...

View Full Version : PHP and variables help!!



cuprasteve
08-31-2006, 12:56 PM
Hi

If I have a PHP page called page1.php thats sets a variable, ie

$myvariable=1;

and i have a PHP page call page2.php that has an include(page1.php);

will it be able to know the value of the variable that is created in the other page?

If not is there a way i can get it to do this?

thanks
steve

amir
08-31-2006, 01:11 PM
u can have the value of page1.php in page2.php, if u have properly included the file.
otherwise u can do it by declaring any variable as Global

cuprasteve
08-31-2006, 01:22 PM
kool how do you declare as a global?

dsavage666
08-31-2006, 09:36 PM
<? global $myvariable1; ?> :thumbsup:

GJay
08-31-2006, 09:47 PM
the_include.php


<?php
echo "this is the include";
$variable='include';
?>


the_page.php


<?php
echo "The main page";
$variable="main_page";
include 'the_include.php';
echo '$variable='.$variable;
?>

will give:


main_page
this is the include
$variable=include



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum