You are here: Re: a variable can to be used in every place « PHP Language « IT news, forums, messages
Re: a variable can to be used in every place

Posted by shimmyshack on 02/23/07 16:48

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация