Reply to Re: include file to global scope

Your name:

Reply:


Posted by cc on 10/13/05 15:09

the answer

cc wrote:
> yes, its possible, consider this:
>
> /**
> * @param $file_to_include path to php file you want to get its content
> * @return included contents
> */
> function get_output($file_to_include){
> ob_start();
> include $file_to_include;
> return ob_get_clean();
> }

is to the question

On 10/12/05, Claudio <karfunckel-php@yahoo.de> wrote:
> Is it possible to process the file in second php instance?
> An only get its output?
>
> Claudio


to ``Is there a way to include this files to global scope? So that difined vars
and functions are global accesseble?'',

there is another answer,

consider these code,

<?php
$ov=1;
function o(){
$iv=1;
function i(){
echo "i\n";
var_dump(get_defined_vars());
}
echo "o\n";
var_dump(get_defined_vars());
i();
}

o();
i();
var_dump(get_defined_vars());


On 10/13/05, Jochem Maas <jochem@iamjochem.com> wrote:
> cc wrote:
> > yes, its possible, consider this:
> >
> > /**
> > * @param $file_to_include path to php file you want to get its content
> > * @return included contents
> > */
> > function get_output($file_to_include){
> > ob_start();
> > include $file_to_include;
> > return ob_get_clean();
> > }
>
> this will break if the included file assumes its being included
> in the global scope (and/or has functions that assume certain globals
> exists - which they would do if the file wasn't included within a
> function) ...
>
> which brings the OP back to his original problem :-)
>
> >
> > of course, you may extend this function to better fit into your
> situation.
> > Good luck.
> >
> > On 10/12/05, Claudio <karfunckel-php@yahoo.de> wrote:
> >
> >>Is it possible to process the file in second php instance?
> >>An only get its output?
> >>
> >>Claudio
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
>
>

[Back to original 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

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