a variable can to be used in every place

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['...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2007
den
 
Posts: n/a
Default a variable can to be used in every place

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.


Reply With Quote
  #2 (permalink)  
Old 02-23-2007
Steve Belanger
 
Posts: n/a
Default Re: a variable can to be used in every place

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.
>
>



Reply With Quote
  #3 (permalink)  
Old 02-23-2007
shimmyshack
 
Posts: n/a
Default Re: a variable can to be used in every place

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:11 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0