Re: Eval() and Extract()

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

 



The two functions print_before() and print_after() run in different scopes.

To be able to get access to $name via the $GLOBALS array in 
print_after(), you will need to declare $name as 'global' within 
print_before().

So change your variable $rs->fields['before'] to be:

$rs->fields['before'] = 'global $name; $name = "Andres";';

and it should work.

--
Rajesh

Andres Santos wrote:
> Hi guys, i need some urgent help at something.
> 
> I have my index.php which executes some code BEFORE printing any
> output, and then executes some code AFTER some of the output has been
> already printed.
> 
> Lets suppose that:
> $rs->fields['before'] = '$name = "Andres";';
> $rs->fields['after'] = 'echo $name;';
> 
> Code:
> 
> <?print_before($rs->fields['before']);?>
> <html>
> ...
> <?print_after($rs->fields['after']);?>
> ...
> </html>
> 
> This an example of the functions:
> Code:
> 
> function print_before($code) {
>  eval($code);
> }
> 
> function print_after($code) {
>  extract($GLOBALS, EXTR_SKIP);
>  eval($code);
> }
> 
> The problem is that print_after() is not getting the $name value that
> has been already seted in print_before().
> 
> Any ideas?


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux