Thread: eval() issue
View Single Post
Old 09-05-2011, 09:48 AM   #1 (permalink)
exangelus
The Visitor
 
Join Date: Sep 2011
Location: Eindhoven, Netherlands
Posts: 4
Thanks: 1
exangelus is on a distinguished road
Default eval() issue

Hey all,

I'm new here and like to join the community to ask & answer!
From the netherlands as a airline pilot student and part-time php programmer :)

At my current project I got a situation in which I call a method from a child class and the parameter's are also defined in a config file. So using the config file info I build up the correct argument order, the variables are defined before that. Now I wanna use eval() to call my method but I get the following error:

Quote:
A PHP Error was encountered

Severity: 4096

Message: Object of class Rapport could not be converted to string

Filename: controllers/rapport.php

Line Number: 62
The code:

PHP Code:
//argumenten ophalen
                
$arguments $rapportages[$rapportage]['arguments'];

                
//argumenten definen
                
foreach($arguments as $arg) {
                    $
$arg false;
                }
                
                
//daadwerkelijk bekende argument definen
                
$$sorteer_methode $sorteer_optie;
                
                
//argumentvolgorde maken voor eval()
                
$arg_order '';
                foreach(
$arguments as $arg) {
                    
$arg_order .= '$' $arg ', ';
                }
                
$arg_order substr($arg_order0, -2);
                
                
//functie aanroepen
                
eval("$this->$method($arg_order)"); 
$sorteer_optie is the argument I know and the others are already set false, this all seems ok but the eval() call doesn't work.
Think I need to escape it in some way but just putting a backward slash in front of $this won't work..

Thanks in advance!
exangelus is offline  
Reply With Quote