RE: Problems with file_get_contents() and local PHP file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm too busy with other matters to try this out right now, but I'll make
sure  to try it later when I can. Thanks!

 

-Mike

 

----- Original Message ----- 

From: ""Jan Reiter"" <the-fallen@xxxxxxx>

Newsgroups: php.general

To: <ceo@xxxxxxxxx>; "'Mike'" <zmen8@xxxxxxx>

Cc: <php-general@xxxxxxxxxxxxx>

Sent: Tuesday, August 07, 2007 11:01 PM

Subject: RE:  Problems with file_get_contents() and local PHP file

 

> D'oh!
> 
> The solution is so simple and clean that it almost hurts. I didn't see it
in
> the first approach!
> 
> There is a way to go all this, without using file() or
file_get_contents()!
> Cuz this would require to use a URL wrapper to retrieve compiled code,
which
> would cost overhead on the local webserver and the internet deamon. 
> 
> Just use and modify this code. You may also put it into a function;
> 
> 
> // I strongly recommend to use this INSIDE a function to get a clear
> namespace
> function get_img_script($parameters)
> {
> 
> // backup $_GET variable
> $getbuffer = $_GET; 
> unset($_GET);
> 
> $_GET = $parameters;
> 
> ob_start();
> include 'yourscript.php';
> $buffer = ob_get_contents();
> Ob_end_clean();
> 
> // restore $_GET variable
> unset($_GET);
> $_GET = $getbuffer;
> 
> return $buffer;
> }
> 
> And call it like this:
> 
> // define variables here. If you'd passed it with ?var=val
> // use
> 
> $param = array('var'=>'val');
> $img = get_img_script($param);
> 
> 
> Hope that solves the problem in a clean way! 
> 
> Jan
> 
>


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux