Sorin Buturugeanu wrote:
> Hello,
>
> I am having trouble with a part of my templating script. I'll try to
> explain:
>
> The template itself is HTML with PHP code inside it, like:
>
>
>
> And I have the following code as part of the templating engine:
>
> $template = file_get_contents($file
Orangehairedboy wrote:
I would like to use eval() to evaluate another PHP file and store the output
of that file in a string.
Personally, I try to avoid using eval(). It can be very useful, but
there are also potential security issues depending on your setup. Based
on what you said in another
You can put whatever you want in eval:
You could even do this:
HTH
Bogdan
Decapode Azur wrote:
Is it possible to put PHP code in eval ?
Or just vars ?
$string = 'The result of ';
eval ($string);
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.
- Original Message -
From: "Shawn McKenzie" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 14, 2003 1:51 PM
Subject: Re: [PHP] Re: Eval var from query
> Thanks Kevin! That works great. It outputs: hi my name is Shawn
>
> Now if I want
PROTECTED]
> > The string you send to eval() must be valid PHP code. So try this..
> >
> > eval( 'echo "'.$data.'";');
> >
> > - Kevin
> >
> >
> > - Original Message -
> > From: "Shawn McKenzie" <
e" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, July 14, 2003 1:15 PM
> Subject: [PHP] Re: Eval var from query
>
>
> > eval($data)
> >
> > returns Parse error: parse error, unexpected T_STRING in
> > C:\apps\apache2\htdocs\te
;";';
$name = 'Shawn';
eval($code); // prints "hi may name is Shawn".
Hope that makes it more clear.
- Kevin
- Original Message -
From: "Kevin Stone" <[EMAIL PROTECTED]>
To: "PHP-GENERAL" <[EMAIL PROTECTED]>
Sent: Monday, J
The string you send to eval() must be valid PHP code. So try this..
eval( 'echo "'.$data.'";');
- Kevin
- Original Message -
From: "Shawn McKenzie" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 14, 2003 1:15 PM
S
eval($data)
returns Parse error: parse error, unexpected T_STRING in
C:\apps\apache2\htdocs\test\query.php(23) : eval()'d code on line 1
Thanks!
Shawn
"Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How can I evaluate a var that is from a text field of a database?
ok - my latest in the eval saga is this:
I want to be able to eval a function call anywhere in the string supplied,
and the function call is not in scope when the string is defined.
So
-- somewhere in my code I wanted something like this:
$string = "testing nodename: \$node->getName()
pagename:
we're in the pipe, 5-5-5.");
$str = "Hello, \$name";
$str2 = "Hello, \$arr[0]";
$str3 = "Hello, \$arr2[".NAME_TAG."]";
echo doEvalWithVarsInScope($str);
echo doEvalWithVarsInScope($str2);
echo doEvalWithVarsInScope($str3);
}
function doEvalWithVarsInScope($str)
{
echo("trying to e
Actually, I just realised that what I want to accomplish is different from
my example - the main issue is with scope:
we're in the pipe, 5-5-5.");
$str = "Hello, \$name";
$str2 = "Hello, \$arr[0]";
$str3 = "Hello, \$arr2['name']";
echo doEvalWithVarsInScope($str);
echo doEvalWithVarsI
Thanks Dan - I just worked this out before reading your solution! :)
$str4 = "Hello, ".$arr2['name'];
cheers and thanks to all - lets see how that goes within my framework now :)
neko
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hi,
> $arr2["name"] = "Broness!";
..
> $str3 = "Hello, $arr2['name']";
..
> eval ("\$evaldString = \"$str3\";");
> echo $evaldString;
Your almost there... just remember one very simple rule - if in doubt,
break out. Meaning, if you're having variable resolution issues, then just
break out of the
note that the following php:
Hello, $name";
$str2 = "Hello, $arr[0]";
$str3 = "Hello, $arr2['name']";
eval ("\$evaldString = \"$str\";");
echo $evaldString;
eval ("\$evaldString = \"$str2\";");
echo $evaldString;
eval ("\$evaldString = \"$str3\";");
echo $evaldString;
?>
produces:
Broness!He
On Monday 21 January 2002 12:17, Alex Dowgailenko wrote:
> After getting very frustrated with arrays, I ended up using eval() in the
> following way:
>
> function top10() {
> $i = 0;
> $res = mysql_query("SELECT orders.pid, products.pid, orders.amount,
> products.pname FROM orders, pro
s angry and depressed that I wasn't getting paid enough for
what I was doing so I took the easy way out. It's the only time I ever used
eval() in PHP.
> -Original Message-
> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
> Sent: January 20, 2002 11:22 PM
> To: Alex Do
> while (list($opid, $ppid, $amount, $pname) = mysql_fetch_row($res)) {
> $eval = '$temp["'.$pname.'"] = $temp["'.$pname.'"] + '.$amount.';';
> eval($eval);
> $i++;
Whoa... Why not simply:
$temp[$pname] += $amount;
??
-Rasmus
--
PHP General M
After getting very frustrated with arrays, I ended up using eval() in the
following way:
function top10() {
$i = 0;
$res = mysql_query("SELECT orders.pid, products.pid, orders.amount,
products.pname FROM orders, products WHERE orders.uid!='' AND
orders.pid=products.pid") or die(my
of cpu and memory
> resources.
Agreed.
Regards,
Kunal Jhunjhunwala
- Original Message -
From: "Michael Waples" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 20, 2002 6:39 PM
Subject: [PHP] Re: eval()
> Kunal Jhunjhunwala wrote:
> >
>
Kunal Jhunjhunwala wrote:
>
> Hey,
> I tend to agree with you. But what is the most effiecent way of using php
> code in template files then? I am not going to move my templates to a
> dbase.. thats for sure.
> Regards,
> Kunal Jhunjhunwala
well for looping through the results of a sql query whe
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
* On 20-01-02 at 13:26
* Kunal Jhunjhunwala said
> Hey,
> I tend to agree with you. But what is the most effiecent way of using php
> code in template files then? I am not going to move my templates to a
> dbase.. thats for sure.
The point of
Hey,
I tend to agree with you. But what is the most effiecent way of using php
code in template files then? I am not going to move my templates to a
dbase.. thats for sure.
Regards,
Kunal Jhunjhunwala
- Original Message -
From: "Michael Waples" <[EMAIL PROTECTED]>
To: "Kunal Jhunjhunwala"
Kunal Jhunjhunwala wrote:
>
> Hey
> Does anybody know if its wise to use eval() ? I know Vbulletin uses it.. but
> there is something about it I just cant digest.. it seems to be a very
> powerfull function which can be very easily exploited... anyone else have
> any thoughts?
> Regards,
> Kunal
"Paul Roberts" <[EMAIL PROTECTED]> wrote in message
000d01c18101$5dbb2220$01f8883e@laptop1">news:000d01c18101$5dbb2220$01f8883e@laptop1...
> Hi
>
> I'm trying to pre-fill a form ( the data is passed via sessions or from
> another script).
>
> i have some check boxes on the form that i would like
25 matches
Mail list logo