This is a discussion on a variable can to be used in every place within the alt.comp.lang.php forums, part of the PHP Programming Forums category; If I have in this dir :\AA\BB\E\F\G\H\I\ one file.php with this variable: $pip['...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
If I have in this dir :\AA\BB\E\F\G\H\I\
one file.php with this variable: $pip['value']=50; If I want to use in other dir's file \AA\BB\CC\ 1) is possible? but I not want to require or include the file.php. I would like use directly the variable. |
|
|||
|
one way you could do that is to save the variable into the user sessions and
retreive it with $_SESSION or something of that nature. "den" <spamnot@not.not> wrote in message news:f02k3n8x5y1b$.1g8bypxw8ag0b.dlg@40tude.net... > If I have in this dir :\AA\BB\E\F\G\H\I\ > one file.php with this variable: > $pip['value']=50; > > If I want to use in other dir's file \AA\BB\CC\ > > 1) is possible? > but I not want to require or include the file.php. > I would like use directly the variable. > > |
|
|||
|
On 23 Feb, 10:25, den <spam...@not.not> wrote:
> If I have in this dir :\AA\BB\E\F\G\H\I\ > one file.php with this variable: > $pip['value']=50; > > If I want to use in other dir's file \AA\BB\CC\ > > 1) is possible? > but I not want to require or include the file.php. > I would like use directly the variable. you have to open the file though right? so unless you treat it as atext file, and have the file like this: $pip['value']=50; $pip['value2']=150; $pip['value3']=150; and use file() to get an array, and split to by = ... or use regular expressions to extract the key=>values the easiest way is to include it, unless there's some reason you can't: file.php: <?php return array ( 'pip' => array ( 'host' => 'localhost', 'user' => 'me', 'pass' => 'strong_3st_in-the-wORld!', 'db' => 'cheese', 'value' => 50, ) ); ?> then in which file you need it, use $arrayInfo = include( 'file.php' ); print_r( $arrayInfo ); but i understand it might not be what youre after |