executing variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thyseus
Forum Newbie
Posts: 2
Joined: Tue Jul 29, 2003 6:58 am
Contact:

executing variables

Post by thyseus »

Hi. following code:

$a = "Hello world";
$b = "echo $a";

Now i want to execute the value of $b, like

$c = EXECUTE($b);

$c should now contain "Hello World";

how do i do this?
thx
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Why do you need this functionality? Depending on exactly what you want to do there could be a few different solutions.

Mac
thyseus
Forum Newbie
Posts: 2
Joined: Tue Jul 29, 2003 6:58 am
Contact:

Post by thyseus »

(object-oriented code)...
I want to create an sql statement like this:

$str = $newobject->strtolower($newclass) . "id";
$val = EXEC($str);
$newobject->search("id", $val);

i have a class for every table. these tables are linked.
the table of $newclass has an column that is called
"newobjectid". The id has to be added to "newobject"
this is why i need this functionality.
the "search" method build the query.
hope this helps....
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

Post by jmarcv »

Try this?

$a = "Hello world";
$b = "echo $a";

$tr = fopen('tmp.inc', "w");
fputs ($tr,$b);
fclose($tr);

include 'tmp.inc';
Post Reply