Page 1 of 1

variables as statements

Posted: Thu Dec 11, 2003 6:00 am
by tmjp.com
Hello,

I'm relatively new to php and was wondering...

...Is it possible to write a statement into a variable, then access the variable as though it were the results of executing the statement?

EG

<?php
$thingamebob = "1 + 1";
echo("$thingamebob");
?>

writes

1 + 1

Is there a way to get it to write

2

without going into complex regexps and stuff.


Hope someone can help.

Posted: Thu Dec 11, 2003 6:14 am
by JayBird
the eval() funtion may be helpful!?

http://se.php.net/manual/en/function.eval.php

Mark

Posted: Thu Dec 11, 2003 6:27 am
by tmjp.com
Yippeee.

Ta. You're a scholar and a gent.

If only I knew what to search for, I'd search for it.

Posted: Thu Dec 11, 2003 6:34 am
by JayBird
google is your friend :)

Posted: Thu Dec 11, 2003 2:36 pm
by AnsonM
Download the PHP manual :D

Posted: Thu Dec 11, 2003 2:46 pm
by Draco_03
You can also (if you use mozilla firebird ..if not you should use it) add a search engine on php.net (by clicking on the google search engine in the toolbar (top right corner) and selecting add engine

Posted: Thu Dec 11, 2003 11:29 pm
by Nay
Or, add a bookmark, but the URL as this:

Code: Select all

javascript: var the_answer = prompt('Which function?', 'Enter here'); document.location = 'http://sg.php.net/' + the_answer;
8).

-Nay

Posted: Thu Dec 11, 2003 11:34 pm
by volka
or create a quicksearch boookmark in your mozilla browser
php -> http://php.net/%s
and type php eval ;)

Posted: Thu Dec 11, 2003 11:37 pm
by Nay
volka <_<...

viewtopic.php?t=15541

Some things never change do they? ;)

-Nay

Posted: Thu Dec 11, 2003 11:53 pm
by volka
we will see ;)