Re: [PHP] eval and HEREDOC

2010-07-21 Thread Peter Lind
On 21 July 2010 06:46, Sorin Buturugeanu m...@soin.ro wrote:
 @Vincent: no, the short tags are not off.

 @Jim: This seamns to work fine:

 $template = file_get_contents(pathTemplates.$this-dir.$this-tpl);
 ob_start();
 $template = eval('?'.$template);
 $template = ob_get_clean();

 Thanks!

 Best wishes!

 Sorin


 --
 Sorin Buturugeanu
 http://www.soin.ro




 On Wed, Jul 21, 2010 at 1:45 AM,  li...@cmsws.com wrote:



 On Wed, 21 Jul 2010 01:04:12 +0300, Sorin Buturugeanu m...@soin.ro wrote:
 Hello Vincent and thank you for your reply :).

 That's true, I forgot to explain how I got to using HEREDOC, so ..

 Using eval(file_get_contents($file)) just outputs the result on the
 spot and I need
 to get the whole output (without echoing it) and do some more things with
 it.

 require_once() doesn't fit here (from what I can tell), because it
 would still just
 include the file in echo the output.

 I think there must be a solution, but I'm missing something here  ..


 Check out the ob_* functions

 You could do this

 ob_start();

 include /your/file.php;

 $output = ob_get_clean();

 echo $output;

 Jim


 Thanks again!

 --
 Sorin Buturugeanu
 http://www.soin.ro


 On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent dae...@daevid.com
 wrote:

  -Original Message-
  From: Sorin Buturugeanu [mailto:m...@soin.ro]
  Sent: Tuesday, July 20, 2010 2:11 PM
  To: php-general@lists.php.net
  Subject: [PHP] eval and HEREDOC
 
  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:
 
  div?=strtoupper($user['name']);?/div
 
  And I have the following code as part of the templating engine:
 
  $template = file_get_contents($file);
  $template = return TEMPLATE\n.$template.\nTEMPLATE;\n;
  $template = eval($template);
 
  The problem is that the eval() HEREDOC combination gives the
  following output:
 
  ?=strtoupper(Array['time']);?
 
  If in the HTML file (template) I use
 
  div?=strtoupper({$user['name']});?/div
 
  I get  ?=strtoupper(username);? as an output.
 
  I have tried closing the php tag like this:
 
  $template = return TEMPLATE\n?.$template.\nTEMPLATE;\n;
 
  but the extra ? only gets outputed as HTML.
 
  This is my first post to this mailing list, so I great you
  all and thank you for any kind of solution to my problem.

 Why are you using HEREDOC to begin with? I personally find them to be
 ugly
 and more trouble than they're worth.

 You can write the same thing as this I think (untested):

 $template = eval(file_get_contents($file));

 But you might also consider using include_once or require_once
 instead
 of this eval() business.

 Also note, that a string can span more than one line and have variables
 in
 it. It can even be used with code, so HEREDOC is again useless for most
 situations:

 $foo = 
 Hello $name,\n
 \n
 Today is .date('Y-m-d').\n
 \n
 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 \n
 Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
 metus, mattis a sollicitudin in, placerat vitae elit.
 \n
 Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.
 ;


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



1) heredoc is great for not caring about escaping ' or . Whether or
not you like the syntax it's not hard to use in any way.
2) stay away from eval. Just don't use it unless you have no other choice
3) the include+output buffering solution is much better. Another
option would be to use markers in your templates and then just replace
them with content. Whether or not that would suit you depends on what
kinds of templates you're making and for what purpose

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval and HEREDOC

2010-07-21 Thread Sorin Buturugeanu
Hi Peter!

In the first version of the template engine I had markers but now I
need more complex conditions or operations inside the template files,
like array of arrays and so on. I really like the freedom to be able
to just open a PHP tag ? ? and use a foreach() or whatever PHP
function as I please.

Thanks again to all of you for your support! :)

Sorin

--
Sorin Buturugeanu
http://www.soin.ro



On Wed, Jul 21, 2010 at 9:47 AM, Peter Lind peter.e.l...@gmail.com wrote:
 On 21 July 2010 06:46, Sorin Buturugeanu m...@soin.ro wrote:
 @Vincent: no, the short tags are not off.

 @Jim: This seamns to work fine:

 $template = file_get_contents(pathTemplates.$this-dir.$this-tpl);
 ob_start();
 $template = eval('?'.$template);
 $template = ob_get_clean();

 Thanks!

 Best wishes!

 Sorin


 --
 Sorin Buturugeanu
 http://www.soin.ro




 On Wed, Jul 21, 2010 at 1:45 AM,  li...@cmsws.com wrote:



 On Wed, 21 Jul 2010 01:04:12 +0300, Sorin Buturugeanu m...@soin.ro wrote:
 Hello Vincent and thank you for your reply :).

 That's true, I forgot to explain how I got to using HEREDOC, so ..

 Using eval(file_get_contents($file)) just outputs the result on the
 spot and I need
 to get the whole output (without echoing it) and do some more things with
 it.

 require_once() doesn't fit here (from what I can tell), because it
 would still just
 include the file in echo the output.

 I think there must be a solution, but I'm missing something here  ..


 Check out the ob_* functions

 You could do this

 ob_start();

 include /your/file.php;

 $output = ob_get_clean();

 echo $output;

 Jim


 Thanks again!

 --
 Sorin Buturugeanu
 http://www.soin.ro


 On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent dae...@daevid.com
 wrote:

  -Original Message-
  From: Sorin Buturugeanu [mailto:m...@soin.ro]
  Sent: Tuesday, July 20, 2010 2:11 PM
  To: php-general@lists.php.net
  Subject: [PHP] eval and HEREDOC
 
  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:
 
  div?=strtoupper($user['name']);?/div
 
  And I have the following code as part of the templating engine:
 
  $template = file_get_contents($file);
  $template = return TEMPLATE\n.$template.\nTEMPLATE;\n;
  $template = eval($template);
 
  The problem is that the eval() HEREDOC combination gives the
  following output:
 
  ?=strtoupper(Array['time']);?
 
  If in the HTML file (template) I use
 
  div?=strtoupper({$user['name']});?/div
 
  I get  ?=strtoupper(username);? as an output.
 
  I have tried closing the php tag like this:
 
  $template = return TEMPLATE\n?.$template.\nTEMPLATE;\n;
 
  but the extra ? only gets outputed as HTML.
 
  This is my first post to this mailing list, so I great you
  all and thank you for any kind of solution to my problem.

 Why are you using HEREDOC to begin with? I personally find them to be
 ugly
 and more trouble than they're worth.

 You can write the same thing as this I think (untested):

 $template = eval(file_get_contents($file));

 But you might also consider using include_once or require_once
 instead
 of this eval() business.

 Also note, that a string can span more than one line and have variables
 in
 it. It can even be used with code, so HEREDOC is again useless for most
 situations:

 $foo = 
 Hello $name,\n
 \n
 Today is .date('Y-m-d').\n
 \n
 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 \n
 Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
 metus, mattis a sollicitudin in, placerat vitae elit.
 \n
 Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.
 ;


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 1) heredoc is great for not caring about escaping ' or . Whether or
 not you like the syntax it's not hard to use in any way.
 2) stay away from eval. Just don't use it unless you have no other choice
 3) the include+output buffering solution is much better. Another
 option would be to use markers in your templates and then just replace
 them with content. Whether or not that would suit you depends on what
 kinds of templates you're making and for what purpose

 Regards
 Peter

 --
 hype
 WWW: http://plphp.dk / http://plind.dk
 LinkedIn: http://www.linkedin.com/in/plind
 BeWelcome/Couchsurfing: Fake51
 Twitter: http://twitter.com/kafe15
 /hype


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval and HEREDOC

2010-07-20 Thread Sorin Buturugeanu
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:

div?=strtoupper($user['name']);?/div

And I have the following code as part of the templating engine:

$template = file_get_contents($file);
$template = return TEMPLATE\n.$template.\nTEMPLATE;\n;
$template = eval($template);

The problem is that the eval() HEREDOC combination gives the following output:

?=strtoupper(Array['time']);?

If in the HTML file (template) I use

div?=strtoupper({$user['name']});?/div

I get  ?=strtoupper(username);? as an output.

I have tried closing the php tag like this:

$template = return TEMPLATE\n?.$template.\nTEMPLATE;\n;

but the extra ? only gets outputed as HTML.

This is my first post to this mailing list, so I great you all and thank you for
any kind of solution to my problem.

Thank you!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] eval and HEREDOC

2010-07-20 Thread Daevid Vincent
 -Original Message-
 From: Sorin Buturugeanu [mailto:m...@soin.ro] 
 Sent: Tuesday, July 20, 2010 2:11 PM
 To: php-general@lists.php.net
 Subject: [PHP] eval and HEREDOC
 
 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:
 
 div?=strtoupper($user['name']);?/div
 
 And I have the following code as part of the templating engine:
 
 $template = file_get_contents($file);
 $template = return TEMPLATE\n.$template.\nTEMPLATE;\n;
 $template = eval($template);
 
 The problem is that the eval() HEREDOC combination gives the 
 following output:
 
 ?=strtoupper(Array['time']);?
 
 If in the HTML file (template) I use
 
 div?=strtoupper({$user['name']});?/div
 
 I get  ?=strtoupper(username);? as an output.
 
 I have tried closing the php tag like this:
 
 $template = return TEMPLATE\n?.$template.\nTEMPLATE;\n;
 
 but the extra ? only gets outputed as HTML.
 
 This is my first post to this mailing list, so I great you 
 all and thank you for any kind of solution to my problem.

Why are you using HEREDOC to begin with? I personally find them to be ugly
and more trouble than they're worth. 

You can write the same thing as this I think (untested):

$template = eval(file_get_contents($file));

But you might also consider using include_once or require_once instead
of this eval() business. 

Also note, that a string can span more than one line and have variables in
it. It can even be used with code, so HEREDOC is again useless for most
situations:

$foo = 
Hello $name,\n
\n
Today is .date('Y-m-d').\n
\n
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
\n
Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
metus, mattis a sollicitudin in, placerat vitae elit. 
\n
Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris. 
;


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval and HEREDOC

2010-07-20 Thread Sorin Buturugeanu
Hello Vincent and thank you for your reply :).

That's true, I forgot to explain how I got to using HEREDOC, so ..

Using eval(file_get_contents($file)) just outputs the result on the
spot and I need
to get the whole output (without echoing it) and do some more things with it.

require_once() doesn't fit here (from what I can tell), because it
would still just
include the file in echo the output.

I think there must be a solution, but I'm missing something here  ..

Thanks again!

--
Sorin Buturugeanu
http://www.soin.ro


On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent dae...@daevid.com wrote:

  -Original Message-
  From: Sorin Buturugeanu [mailto:m...@soin.ro]
  Sent: Tuesday, July 20, 2010 2:11 PM
  To: php-general@lists.php.net
  Subject: [PHP] eval and HEREDOC
 
  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:
 
  div?=strtoupper($user['name']);?/div
 
  And I have the following code as part of the templating engine:
 
  $template = file_get_contents($file);
  $template = return TEMPLATE\n.$template.\nTEMPLATE;\n;
  $template = eval($template);
 
  The problem is that the eval() HEREDOC combination gives the
  following output:
 
  ?=strtoupper(Array['time']);?
 
  If in the HTML file (template) I use
 
  div?=strtoupper({$user['name']});?/div
 
  I get  ?=strtoupper(username);? as an output.
 
  I have tried closing the php tag like this:
 
  $template = return TEMPLATE\n?.$template.\nTEMPLATE;\n;
 
  but the extra ? only gets outputed as HTML.
 
  This is my first post to this mailing list, so I great you
  all and thank you for any kind of solution to my problem.

 Why are you using HEREDOC to begin with? I personally find them to be ugly
 and more trouble than they're worth.

 You can write the same thing as this I think (untested):

 $template = eval(file_get_contents($file));

 But you might also consider using include_once or require_once instead
 of this eval() business.

 Also note, that a string can span more than one line and have variables in
 it. It can even be used with code, so HEREDOC is again useless for most
 situations:

 $foo = 
 Hello $name,\n
 \n
 Today is .date('Y-m-d').\n
 \n
 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 \n
 Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
 metus, mattis a sollicitudin in, placerat vitae elit.
 \n
 Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.
 ;


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval and HEREDOC

2010-07-20 Thread lists





On Wed, 21 Jul 2010 01:04:12 +0300, Sorin Buturugeanu m...@soin.ro wrote:

 Hello Vincent and thank you for your reply :).

 

 That's true, I forgot to explain how I got to using HEREDOC, so ..

 

 Using eval(file_get_contents($file)) just outputs the result on the

 spot and I need

 to get the whole output (without echoing it) and do some more things with

 it.

 

 require_once() doesn't fit here (from what I can tell), because it

 would still just

 include the file in echo the output.

 

 I think there must be a solution, but I'm missing something here  ..





Check out the ob_* functions



You could do this



ob_start();



include /your/file.php;



$output = ob_get_clean();



echo $output;



Jim



 

 Thanks again!

 

 --

 Sorin Buturugeanu

 http://www.soin.ro

 

 

 On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent dae...@daevid.com

 wrote:



  -Original Message-

  From: Sorin Buturugeanu [mailto:m...@soin.ro]

  Sent: Tuesday, July 20, 2010 2:11 PM

  To: php-general@lists.php.net

  Subject: [PHP] eval and HEREDOC

 

  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:

 

  div?=strtoupper($user['name']);?/div

 

  And I have the following code as part of the templating engine:

 

  $template = file_get_contents($file);

  $template = return TEMPLATE\n.$template.\nTEMPLATE;\n;

  $template = eval($template);

 

  The problem is that the eval() HEREDOC combination gives the

  following output:

 

  ?=strtoupper(Array['time']);?

 

  If in the HTML file (template) I use

 

  div?=strtoupper({$user['name']});?/div

 

  I get  ?=strtoupper(username);? as an output.

 

  I have tried closing the php tag like this:

 

  $template = return TEMPLATE\n?.$template.\nTEMPLATE;\n;

 

  but the extra ? only gets outputed as HTML.

 

  This is my first post to this mailing list, so I great you

  all and thank you for any kind of solution to my problem.



 Why are you using HEREDOC to begin with? I personally find them to be

 ugly

 and more trouble than they're worth.



 You can write the same thing as this I think (untested):



 $template = eval(file_get_contents($file));



 But you might also consider using include_once or require_once

 instead

 of this eval() business.



 Also note, that a string can span more than one line and have variables

 in

 it. It can even be used with code, so HEREDOC is again useless for most

 situations:



 $foo = 

 Hello $name,\n

 \n

 Today is .date('Y-m-d').\n

 \n

 Lorem ipsum dolor sit amet, consectetur adipiscing elit.

 \n

 Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue

 metus, mattis a sollicitudin in, placerat vitae elit.

 \n

 Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.

 ;



 

 --

 PHP General Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval and HEREDOC

2010-07-20 Thread Sorin Buturugeanu
@Vincent: no, the short tags are not off.

@Jim: This seamns to work fine:

$template = file_get_contents(pathTemplates.$this-dir.$this-tpl);
ob_start();
$template = eval('?'.$template);
$template = ob_get_clean();

Thanks!

Best wishes!

Sorin


--
Sorin Buturugeanu
http://www.soin.ro




On Wed, Jul 21, 2010 at 1:45 AM,  li...@cmsws.com wrote:



 On Wed, 21 Jul 2010 01:04:12 +0300, Sorin Buturugeanu m...@soin.ro wrote:
 Hello Vincent and thank you for your reply :).

 That's true, I forgot to explain how I got to using HEREDOC, so ..

 Using eval(file_get_contents($file)) just outputs the result on the
 spot and I need
 to get the whole output (without echoing it) and do some more things with
 it.

 require_once() doesn't fit here (from what I can tell), because it
 would still just
 include the file in echo the output.

 I think there must be a solution, but I'm missing something here  ..


 Check out the ob_* functions

 You could do this

 ob_start();

 include /your/file.php;

 $output = ob_get_clean();

 echo $output;

 Jim


 Thanks again!

 --
 Sorin Buturugeanu
 http://www.soin.ro


 On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent dae...@daevid.com
 wrote:

  -Original Message-
  From: Sorin Buturugeanu [mailto:m...@soin.ro]
  Sent: Tuesday, July 20, 2010 2:11 PM
  To: php-general@lists.php.net
  Subject: [PHP] eval and HEREDOC
 
  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:
 
  div?=strtoupper($user['name']);?/div
 
  And I have the following code as part of the templating engine:
 
  $template = file_get_contents($file);
  $template = return TEMPLATE\n.$template.\nTEMPLATE;\n;
  $template = eval($template);
 
  The problem is that the eval() HEREDOC combination gives the
  following output:
 
  ?=strtoupper(Array['time']);?
 
  If in the HTML file (template) I use
 
  div?=strtoupper({$user['name']});?/div
 
  I get  ?=strtoupper(username);? as an output.
 
  I have tried closing the php tag like this:
 
  $template = return TEMPLATE\n?.$template.\nTEMPLATE;\n;
 
  but the extra ? only gets outputed as HTML.
 
  This is my first post to this mailing list, so I great you
  all and thank you for any kind of solution to my problem.

 Why are you using HEREDOC to begin with? I personally find them to be
 ugly
 and more trouble than they're worth.

 You can write the same thing as this I think (untested):

 $template = eval(file_get_contents($file));

 But you might also consider using include_once or require_once
 instead
 of this eval() business.

 Also note, that a string can span more than one line and have variables
 in
 it. It can even be used with code, so HEREDOC is again useless for most
 situations:

 $foo = 
 Hello $name,\n
 \n
 Today is .date('Y-m-d').\n
 \n
 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 \n
 Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
 metus, mattis a sollicitudin in, placerat vitae elit.
 \n
 Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.
 ;


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval uquestion

2008-03-19 Thread chetan rane
HI All

I have the follwoing code

function cleanufx($str){
  return ucase($str);
}

$value=xyz;
$var =ufx;
$fn=clean$var($value);
$val =eval($fn;);
echo $val;

can anyone tell me what is wrong in this as the eval is returning 0 (false);

-- 
Have A pleasant Day
Chetan. D. Rane
Location: India
Contact: +91-9986057255
other ID: [EMAIL PROTECTED]
[EMAIL PROTECTED]


Re: [PHP] eval uquestion

2008-03-19 Thread Andrew Ballard
On Wed, Mar 19, 2008 at 3:22 PM, chetan rane [EMAIL PROTECTED] wrote:
 HI All

  I have the follwoing code

  function cleanufx($str){
   return ucase($str);
  }

  $value=xyz;
  $var =ufx;
  $fn=clean$var($value);
  $val =eval($fn;);
  echo $val;

  can anyone tell me what is wrong in this as the eval is returning 0 (false);


Lots. For starters, this won't even compile. You aren't closing quotes
on the line where you assign a value to $fn. You also don't need
quotes around $fn in your eval statement. There isn't a PHP function
named ucase (unless you declared it elsewhere). I'm guessing you meant
strtoupper(). Besides, eval opens up potential security problems that
can easily be avoided for what you are trying to do here. Assuming
your actual logic is more complex than the example you have shown here
and this approach is actually necessary, why not do this?

function cleanufx($str){
 return strtoupper($str);
}

$value=xyz;
$var =ufx;
$fn=clean$var;
$val = call_user_func($fn, $value);
echo $val;



Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP eval() fatal error

2007-08-27 Thread Maarten Balliauw
When re-writing this example to a form of create_function, the same 
problem occurs:


?php
$code = '  return 12*A+;  '; // Clearly incorrect code :-)
$returnValue = 0;

// Evaluate formula
try {
	$temporaryCalculationFunction = @create_function('', $code); // E_ERROR 
here

if ($temporaryCalculationFunction === FALSE) {
$returnValue = '#N/A';
} else {
   		$returnValue = call_user_func_array($temporaryCalculationFunction, 
array());

}
} catch (Exception $ex) {
$returnValue = '#N/A';
}
?

Now I would expect that when I feed create_function invalid code 
(syntax), the function returns false. It doesn't!


E_ERROR is thrown right away. In my opinion, this should return FALSE, 
and only throw an E_ERROR when the created function is executed...


Before telling me to read the manual: I did over a hundred times, on 
both eval and create_function: create_function is not documented to 
throw E_ERROR right away, instead returning FALSE on error... Exactly 
what I was thinking using the above code.


Now let's repeat my question: is there any way to gracefully evaluate 
specific code, eventually catch an error and respond to that, without 
using parsekit() or launching another process to get this done?


Regards,
Maarten

PS: Eval/create_function is in place in my code, I don't see any other 
method to execute (filtered, of course !!!) PHP code that is embedded in 
a string.



Maarten Balliauw wrote:
Here's the thing: I'm trying to do some dynamic code compilation within 
PHP using eval(). The code I'm trying to compile raises an E_ERROR (Fatal).


Here's a simple example:

?php
$code = '  $returnValue = 12*A+;  '; // Clearly incorrect code :-)
$returnValue = 0;

eval($code);
?

Now, I'd like to catch the error made by eval:

// ...
try {
  eval($code);
} catch (Exception $ex) {
  var_dump($ex);
}
// ...

Problem persists: a fatal error occurs.
Using set_error_handler() and set_exception_handler() is not working 
either...


Is there any way to gracefully catch this error?

Regards,
Maarten


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP eval() fatal error

2007-08-27 Thread Richard Lynch
On Mon, August 27, 2007 12:59 am, Maarten Balliauw wrote:
 Now let's repeat my question: is there any way to gracefully evaluate
 specific code, eventually catch an error and respond to that, without
 using parsekit() or launching another process to get this done?

I missed that you had an E_ERROR parse error.  Sorry.

To answer your question:

No.



You may want to look at various testing frameworks for PHP such as
php_unit and the make test of PHP itself to see how they run tests
such that syntax errors in individual tests don't halt the whole
process.

I know for sure the PHP make test fires off a separate PHP process.

Keep in mind that you're asking PHP to try to execute code that it
can't even parse to start with...  Rather like expecting to get an
a.out from a C program that doesn't compile.  Not gonna happen.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP eval() fatal error

2007-08-26 Thread Richard Lynch
On Mon, August 20, 2007 8:54 am, Maarten Balliauw wrote:
 Here's the thing: I'm trying to do some dynamic code compilation
 within
 PHP using eval(). The code I'm trying to compile raises an E_ERROR
 (Fatal).

 Here's a simple example:

 ?php
 $code = '  $returnValue = 12*A+;  '; // Clearly incorrect code :-)
 $returnValue = 0;

 eval($code);
 ?

 Now, I'd like to catch the error made by eval:

 // ...
 try {
eval($code);
 } catch (Exception $ex) {
var_dump($ex);
 }
 // ...

 Problem persists: a fatal error occurs.
 Using set_error_handler() and set_exception_handler() is not working
 either...

 Is there any way to gracefully catch this error?

I would expect that you need to wrap the try catch block *IN* the code
to be eval'd...

You sound like you know what you're doing, but I'm still gonna say it:

If eval is the solution, you probably didn't understand the problem. :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP eval() fatal error

2007-08-20 Thread Maarten Balliauw
Here's the thing: I'm trying to do some dynamic code compilation within 
PHP using eval(). The code I'm trying to compile raises an E_ERROR (Fatal).


Here's a simple example:

?php
$code = '  $returnValue = 12*A+;  '; // Clearly incorrect code :-)
$returnValue = 0;

eval($code);
?

Now, I'd like to catch the error made by eval:

// ...
try {
  eval($code);
} catch (Exception $ex) {
  var_dump($ex);
}
// ...

Problem persists: a fatal error occurs.
Using set_error_handler() and set_exception_handler() is not working 
either...


Is there any way to gracefully catch this error?

Regards,
Maarten

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP eval() fatal error

2007-08-20 Thread Stut

Maarten Balliauw wrote:
Here's the thing: I'm trying to do some dynamic code compilation within 
PHP using eval(). The code I'm trying to compile raises an E_ERROR (Fatal).


Here's a simple example:

?php
$code = '  $returnValue = 12*A+;  '; // Clearly incorrect code :-)
$returnValue = 0;

eval($code);
?

Now, I'd like to catch the error made by eval:

// ...
try {
  eval($code);
} catch (Exception $ex) {
  var_dump($ex);
}
// ...

Problem persists: a fatal error occurs.
Using set_error_handler() and set_exception_handler() is not working 
either...


Is there any way to gracefully catch this error?


Fatal errors are exactly that... fatal. You cannot catch them or recover 
from them.


Your best option is to shell out another PHP process, capture the output 
and parse that for error messages.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP eval() fatal error

2007-08-20 Thread M. Sokolewicz

Maarten Balliauw wrote:
Here's the thing: I'm trying to do some dynamic code compilation within 
PHP using eval(). The code I'm trying to compile raises an E_ERROR (Fatal).


Here's a simple example:

?php
$code = '  $returnValue = 12*A+;  '; // Clearly incorrect code :-)
$returnValue = 0;

eval($code);
?

Now, I'd like to catch the error made by eval:

// ...
try {
  eval($code);
} catch (Exception $ex) {
  var_dump($ex);
}
// ...

Problem persists: a fatal error occurs.
Using set_error_handler() and set_exception_handler() is not working 
either...


Is there any way to gracefully catch this error?

Regards,
Maarten


If you read the manual (RTFM) at http://www.php.net/eval you'll notice 
the following:


If there is a parse error in the evaluated code, eval() returns FALSE 
and execution of the following code continues normally. It is not 
possible to catch a parse error in eval()  using set_error_handler().


Note:  In case of a fatal error in the evaluated code, the whole script 
exits.



So, no.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Eval To String

2005-12-07 Thread Shaun
Hi,

Is it possible to return the result of eval function to a string rather than 
outputting directly to the browser?

Thanks for your advice 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Eval To String

2005-12-07 Thread Jay Blanchard
[snip]
Is it possible to return the result of eval function to a string rather than

outputting directly to the browser?

Thanks for your advice 
[/snip]

Yes.

You're welcome.

The first freakin' example in TFM http://www.php.net/eval is this;

?php
$string = 'cup';
$name = 'coffee';
$str = 'This is a $string with my $name in it.';
echo $str. \n;
eval(\$str = \$str\;);
echo $str. \n;
? 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Eval To String

2005-12-07 Thread David Grant
Shaun

Shaun wrote:
 Is it possible to return the result of eval function to a string rather than 
 outputting directly to the browser?

ob_start();
eval('$eval = evil;');
$output = ob_get_clean();

Cheers,

David Grant
-- 
David Grant
http://www.grant.org.uk/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval();

2005-10-30 Thread John Taylor-Johnston
I need to generate embedded php within in a mysql record. $contents is 
the actual contents of that record.


?php
$contents = div class=\indent\ style=\font-size: 16px; font-family: 
arial,helvetica; font-weight: bold;\About the Project/div

?php echo \hello world\; ?;
echo eval($contents);
?

I get this error:
Parse error: parse error in /var/www/html2/test.php(4) : eval()'d code 
on line 1


If I just echo $contents, my browser spits out:

div class=indent style=font-size: 16px; font-family: 
arial,helvetica; font-weight: bold;About the Project/div

?php echo hello world; ?

What's wrong? eval() is the correct thing to do, I thought?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval();

2005-10-30 Thread Jasper Bryant-Greene
On Sun, 2005-10-30 at 21:16 -0500, John Taylor-Johnston wrote:
 I need to generate embedded php within in a mysql record. $contents is 
 the actual contents of that record.
 
 ?php
 $contents = div class=\indent\ style=\font-size: 16px; font-family: 
 arial,helvetica; font-weight: bold;\About the Project/div
 ?php echo \hello world\; ?;
 echo eval($contents);
 ?
 
 I get this error:
 Parse error: parse error in /var/www/html2/test.php(4) : eval()'d code 
 on line 1
 
 If I just echo $contents, my browser spits out:
 
 div class=indent style=font-size: 16px; font-family: 
 arial,helvetica; font-weight: bold;About the Project/div
 ?php echo hello world; ?
 
 What's wrong? eval() is the correct thing to do, I thought?
 

eval() expects PHP code, not HTML with embedded PHP code. Try this
(untested):

eval(  ? $contents ?php  );

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
b: http://jbg.name/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval();

2005-10-30 Thread John Taylor-Johnston

?php

$contents = div class=\indent\ style=\font-size: 16px; font-family: 
arial,helvetica; font-weight: bold;\About the Project/div

?php echo \hello world\; ?;
echo eval($contents);
?
eval() expects PHP code, not HTML with embedded PHP code. Try this
(untested):

eval(  ? $contents ?php  );

   


Scary. But it works.
Shouldn't that error because of the unexpected ? and ?php in a bigger 
example?

John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval();

2005-10-30 Thread Jasper Bryant-Greene
On Sun, 2005-10-30 at 21:24 -0500, John Taylor-Johnston wrote:
 ?php
 
 $contents = div class=\indent\ style=\font-size: 16px; font-family: 
 arial,helvetica; font-weight: bold;\About the Project/div
 ?php echo \hello world\; ?;
 echo eval($contents);
 ?
 eval() expects PHP code, not HTML with embedded PHP code. Try this
 (untested):
 
 eval(  ? $contents ?php  );
 
 Scary. But it works.
 Shouldn't that error because of the unexpected ? and ?php in a bigger 
 example?

No, because eval(), when passed string $str, effectively does this
silently:

$str = ?php  . $str .  ?;

and then passes $str to the PHP interpreter.

Which is, in most cases, what you want, because you want to evaluate PHP
code.

However, if eval() is the answer, you're probably asking the wrong
question. You should take a hard look at your code and think of a better
way to do what you need to do.

I can assure you one does exist, but with your example it's fairly
obvious, so you'd need to explain better what you're trying to do before
I could help you.

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
b: http://jbg.name/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval();

2005-10-30 Thread John Taylor-Johnston

eval(  ? $contents ?php  );


However, if eval() is the answer, you're probably asking the wrong
question. You should take a hard look at your code and think of a better
way to do what you need to do.
 

Back to the drawing board? It is either store my html+embedded code in a 
mysql record, or in an html file, which means playing with fopen. It's 
easier to hand tweak in phpmyadmin.

Nonetheless, even though your test code worked (thanks!) this doesn't. Sigh.

if ($contents = displaynew()) eval(  ? $contents ?php  );

function displaynew()
{
  $file = basename($_SERVER['PHP_SELF']);
  require 'connect.inc';
  $sql = SELECT HTML FROM `$db`.`$table_editor` WHERE `Filename`  LIKE 
'.addslashes($file).' LIMIT 1;;

  if ($myquery = mysql_query($sql) and mysql_num_rows($myquery)  0) {
  $mydata = mysql_fetch_array($myquery, MYSQL_NUM);
  return $mydata[0];
  }
  return false;
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval();

2005-10-30 Thread Richard Lynch
On Sun, October 30, 2005 8:51 pm, John Taylor-Johnston wrote:
 eval(  ? $contents ?php  );

However, if eval() is the answer, you're probably asking the wrong
question. You should take a hard look at your code and think of a
 better
way to do what you need to do.


 Back to the drawing board? It is either store my html+embedded code in
 a
 mysql record, or in an html file, which means playing with fopen. It's
 easier to hand tweak in phpmyadmin.
 Nonetheless, even though your test code worked (thanks!) this doesn't.
 Sigh.

 if ($contents = displaynew()){
echo CONTENTS:pre, htmlentities($contents), /pre\n;
 eval(  ? $contents ?php  );
}

I'm guessing $contents ain't what you think.



 function displaynew()
 {
$file = basename($_SERVER['PHP_SELF']);
require 'connect.inc';
$sql = SELECT HTML FROM `$db`.`$table_editor` WHERE `Filename`
 LIKE
 '.addslashes($file).' LIMIT 1;;
if ($myquery = mysql_query($sql) and mysql_num_rows($myquery)  0)

This 'and' should probably be '' ...

Though I never really used 'and' enough to know for sure.

At any rate, you've got *NO* error-checking for an invalid query here.

 {
$mydata = mysql_fetch_array($myquery, MYSQL_NUM);
return $mydata[0];
}
return false;
 }


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] eval();

2005-10-30 Thread Josh McDonald
Keep in mind, eval()ing code you pull from the database will also raise the
damage from a SQL injection attack or similar from a PITA
restore-your-database to a much bigger PITA format-webserver.

-Josh
 
--
 
My name was Brian McGee
I stayed up listening to Queen
When I was seventeen

  Josh 'G-Funk' McDonald  ::  Pirion Systems, Brisbane
 
 07 3257 0490  ::  0437 221 380  ::  [EMAIL PROTECTED]
 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Monday, 31 October 2005 3:57 PM
To: John Taylor-Johnston
Cc: php-general@lists.php.net; Jasper Bryant-Greene
Subject: Re: [PHP] eval();

On Sun, October 30, 2005 8:51 pm, John Taylor-Johnston wrote:
 eval(  ? $contents ?php  );

However, if eval() is the answer, you're probably asking the wrong 
question. You should take a hard look at your code and think of a  
better way to do what you need to do.


 Back to the drawing board? It is either store my html+embedded code in 
 a mysql record, or in an html file, which means playing with fopen. 
 It's easier to hand tweak in phpmyadmin.
 Nonetheless, even though your test code worked (thanks!) this doesn't.
 Sigh.

 if ($contents = displaynew()){
echo CONTENTS:pre, htmlentities($contents), /pre\n;  eval(  ?
$contents ?php  ); }

I'm guessing $contents ain't what you think.



 function displaynew()
 {
$file = basename($_SERVER['PHP_SELF']);
require 'connect.inc';
$sql = SELECT HTML FROM `$db`.`$table_editor` WHERE `Filename` 
 LIKE '.addslashes($file).' LIMIT 1;;
if ($myquery = mysql_query($sql) and mysql_num_rows($myquery)  0)

This 'and' should probably be '' ...

Though I never really used 'and' enough to know for sure.

At any rate, you've got *NO* error-checking for an invalid query here.

 {
$mydata = mysql_fetch_array($myquery, MYSQL_NUM);
return $mydata[0];
}
return false;
 }


--
Like Music?
http://l-i-e.com/artists.htm

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Eval string to array

2005-01-24 Thread Gerard Samuel
Im trying to evaluate a string representation of the output of 
var_export(),
as an array.
To make a long story short, Im using curl to fetch another php page,
that uses var_export to echo out php data structures.
The fetched data via curl, is a string.  Something like -
array ( 'foo' = 'bar', )

I would like to convert this to a real array.
Im currently trying this -
$ret = curl_exec($this-curl_handle);
$str = '$array = $ret;';
eval($str);
var_dump($ret, $array);
The resulting var_dump() shows that my eval'ed data is still a string.
string(27) array ( 'foo' = 'bar', ) string(27) array ( 'foo' = 
'bar', )
What should I be doing to get it as an array -
array(1) { [foo]= string(3) bar }

Thanks for your time.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Eval string to array

2005-01-24 Thread Jochem Maas
Gerard Samuel wrote:
Im trying to evaluate a string representation of the output of 
var_export(),
as an array.
To make a long story short, Im using curl to fetch another php page,
that uses var_export to echo out php data structures.
The fetched data via curl, is a string.  Something like -
array ( 'foo' = 'bar', )
something LIKE? or exactly that?
anyway I don't have problems with this...
php -r '
eval(\$arr = array ( \foo\ = \bar\, ););
$arr1 = var_export($arr, true);
eval(\$arr2 = $arr1;);
var_dump($arr,$arr1,$arr2);
'
...took me a couple of
mins to figure out how you could be
I would like to convert this to a real array.
Im currently trying this -
$ret = curl_exec($this-curl_handle);
$str = '$array = $ret;';
this is your problems. its to do with string interpolation.
your exec() call is equivelant to
$array = $ret;
guess what that makes $array?
so it should be:
exec(\$array = $ret;);
which will replace the string $ret into the string to be
exec()'ed. alternatively:
exec('$array = '.$ret.';');
geddit?
eval($str);
var_dump($ret, $array);
next time paste the actual var_dump output, its easier. :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Eval string to array

2005-01-24 Thread Gerard Samuel
Jochem Maas wrote:
Gerard Samuel wrote:
Im trying to evaluate a string representation of the output of 
var_export(),
as an array.
To make a long story short, Im using curl to fetch another php page,
that uses var_export to echo out php data structures.
The fetched data via curl, is a string.  Something like -
array ( 'foo' = 'bar', )

something LIKE? or exactly that?
anyway I don't have problems with this...
php -r '
eval(\$arr = array ( \foo\ = \bar\, ););
$arr1 = var_export($arr, true);
eval(\$arr2 = $arr1;);
var_dump($arr,$arr1,$arr2);
'
...took me a couple of
mins to figure out how you could be

For now, exactly like.
This is what I extracted from your example for it to work -
$ret = str_replace(\n, '', curl_exec($this-curl_handle));
eval(\$arr = $ret;);
$arr1 = var_export($arr, true);
var_dump($arr);

I would like to convert this to a real array.
Im currently trying this -
$ret = curl_exec($this-curl_handle);
$str = '$array = $ret;';

this is your problems. its to do with string interpolation.
your exec() call is equivelant to
$array = $ret;
guess what that makes $array?
so it should be:
exec(\$array = $ret;);
which will replace the string $ret into the string to be
exec()'ed. alternatively:
exec('$array = '.$ret.';');
geddit?

gotit

eval($str);
var_dump($ret, $array);

next time paste the actual var_dump output, its easier. :-)

It was in the original email.  Just not where you thought it would have 
been ;)

Thanks for your help.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] eval() with CONSTANTS

2004-05-20 Thread Greg Donald

How can I eval() an HTML template to make a CONSTANT be evaluated
properly?

Previously I have been using regular $variables in my HTML templates.
Today I decided to make one of the $variables a CONSTANT only to find it
would not parse out as it's defined value.  It is instead treated as
regular text.  I tried wrapping the CONSTANT with curly braces, and also
tried using the constant() function with it in the HTML template. 
Neither return the value I previously defined with define().  The manual
says Constants may be defined and accessed anywhere without regard to
variable scoping rules but I'm missing something.

I do:

define('TABLE_PARAMETERS', ' border=0 cellspacing=0 cellpadding=0');

Then I get and eval() my template:

$index = getTemplate('index');
eval(\$index = \$index\;);

And I end up with HTML that looks like:

table {TABLE_PARAMETERS}

instead of the desired

table border=0 cellspacing=0 cellpadding=0 

Any ideas?  I've google'd, and read lots of docs today trying to figure
it out but I don't know what else to try.

TIA.

-- 
Greg Donald
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval() with CONSTANTS

2004-05-20 Thread Tom Rogers
Hi,

Friday, May 21, 2004, 8:26:30 AM, you wrote:

GD How can I eval() an HTML template to make a CONSTANT be evaluated
GD properly?

GD Previously I have been using regular $variables in my HTML templates.
GD Today I decided to make one of the $variables a CONSTANT only to find it
GD would not parse out as it's defined value.  It is instead treated as
GD regular text.  I tried wrapping the CONSTANT with curly braces, and also
GD tried using the constant() function with it in the HTML template. 
GD Neither return the value I previously defined with define().  The manual
GD says Constants may be defined and accessed anywhere without regard to
GD variable scoping rules but I'm missing something.

GD I do:

GD define('TABLE_PARAMETERS', ' border=0 cellspacing=0 cellpadding=0');

GD Then I get and eval() my template:

GD $index = getTemplate('index');
GD eval(\$index = \$index\;);

GD And I end up with HTML that looks like:

GD table {TABLE_PARAMETERS}

GD instead of the desired

GD table border=0 cellspacing=0 cellpadding=0 

GD Any ideas?  I've google'd, and read lots of docs today trying to figure
GD it out but I don't know what else to try.

GD TIA.

GD -- 
GD Greg Donald
GD [EMAIL PROTECTED]


There is no way for php to what is a constant and what is text so you
have to put it in a variable to use it in a string.

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval() question

2004-04-21 Thread OrangeHairedBoy
I would like to use eval() to evaluate another PHP file and store the output
of that file in a string.

So, let's say, for example, that I have a file called colors.php which
contains this:

pColors: ? echo Red, Yellow, Green, Blue; ?/p

Then, in another file, I have this:

$file = file_get_contents( colors.php );
$colors = eval( $file );

I'm having problems getting $file into $colors. How can I do this?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] eval() question

2004-04-21 Thread Michael Sims
OrangeHairedBoy wrote:
 I would like to use eval() to evaluate another PHP file and store the
 output of that file in a string.

You could use output buffering to do this a bit more easily, I think:

ob_start();
include('colors.php');
$colors = ob_get_contents();
ob_end_clean();

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval() question

2004-04-21 Thread OrangeHairedBoy
While that is an awesome idea, I don't think it will work for me.

There's two reasons why. First, colors.php is actually stored in a MySQL
server.

Second, before the PHP code inside colors.php I want to be able to replace
data inside that file. For example:

$file = str_replace( Green , Orange , $file );

Lewis


Michael Sims [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 OrangeHairedBoy wrote:
  I would like to use eval() to evaluate another PHP file and store the
  output of that file in a string.

 You could use output buffering to do this a bit more easily, I think:

 ob_start();
 include('colors.php');
 $colors = ob_get_contents();
 ob_end_clean();

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval() question

2004-04-21 Thread Marek Kilimajer
OrangeHairedBoy wrote:
I would like to use eval() to evaluate another PHP file and store the output
of that file in a string.
So, let's say, for example, that I have a file called colors.php which
contains this:
pColors: ? echo Red, Yellow, Green, Blue; ?/p

Then, in another file, I have this:

$file = file_get_contents( colors.php );
$colors = eval( $file );
I'm having problems getting $file into $colors. How can I do this?

eval starts in php mode by default, change the file content to

?pColors: ? echo Red, Yellow, Green, Blue; ?/p?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] eval() question

2004-04-21 Thread OrangeHairedBoy
Marek,

OK...that worked...kinda, but it doesn't pass the output to $colors. It
echos it. I need the output to be passed to $colors.

Lewis

Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 OrangeHairedBoy wrote:
  I would like to use eval() to evaluate another PHP file and store the
output
  of that file in a string.
 
  So, let's say, for example, that I have a file called colors.php which
  contains this:
 
  pColors: ? echo Red, Yellow, Green, Blue; ?/p
 
  Then, in another file, I have this:
 
  $file = file_get_contents( colors.php );
  $colors = eval( $file );
 
  I'm having problems getting $file into $colors. How can I do this?
 

 eval starts in php mode by default, change the file content to

 ?pColors: ? echo Red, Yellow, Green, Blue; ?/p?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] eval() question

2004-04-21 Thread Michael Sims
 OrangeHairedBoy wrote:
 I would like to use eval() to evaluate another PHP file and store
 the output of that file in a string.

 You could use output buffering to do this a bit more easily, I think:

 ob_start();
 include('colors.php');
 $colors = ob_get_contents();
 ob_end_clean();

 While that is an awesome idea, I don't think it will work for me.

 There's two reasons why. First, colors.php is actually stored in a
 MySQL server.

 Second, before the PHP code inside colors.php I want to be able to
 replace data inside that file. For example:

 $file = str_replace( Green , Orange , $file );

Ok, then a slight adjustment should work:

$file = file_get_contents( colors.php );
$file = str_replace( Green , Orange , $file );
ob_start();
eval( $file );
$colors = ob_get_contents();
ob_end_clean();

I've never done that personally, but the documentation for eval() states:

In PHP 4, eval() returns NULL unless return is called in the evaluated code,
in which case the value passed to return is returned.

And then:

Tip: As with anything that outputs its result directly to the browser, you
can use the output-control functions to capture the output of this function,
and save it in a string (for example).

HTH...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval() question

2004-04-21 Thread OrangeHairedBoy
Thanks Michael  Marek! It worked! :)


Michael Sims [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  OrangeHairedBoy wrote:
  I would like to use eval() to evaluate another PHP file and store
  the output of that file in a string.
 
  You could use output buffering to do this a bit more easily, I think:
 
  ob_start();
  include('colors.php');
  $colors = ob_get_contents();
  ob_end_clean();
 
  While that is an awesome idea, I don't think it will work for me.
 
  There's two reasons why. First, colors.php is actually stored in a
  MySQL server.
 
  Second, before the PHP code inside colors.php I want to be able to
  replace data inside that file. For example:
 
  $file = str_replace( Green , Orange , $file );

 Ok, then a slight adjustment should work:

 $file = file_get_contents( colors.php );
 $file = str_replace( Green , Orange , $file );
 ob_start();
 eval( $file );
 $colors = ob_get_contents();
 ob_end_clean();

 I've never done that personally, but the documentation for eval() states:

 In PHP 4, eval() returns NULL unless return is called in the evaluated
code,
 in which case the value passed to return is returned.

 And then:

 Tip: As with anything that outputs its result directly to the browser, you
 can use the output-control functions to capture the output of this
function,
 and save it in a string (for example).

 HTH...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval function

2003-08-23 Thread Matthias Wulkow
Hallo Tom,

am Samstag, 23. August 2003 um 05:14 hast Du Folgendes gekritzelt:


TR This should do it:

TR eval('${content.$databasepagename}[$i]();');

I'm afraid to say it, but it does not :-(

Yesterday I was also trying to find some manual pages about eval()
which would explain me the syntax. The example in the PHP-Manual is
not meaning much to me.

How can I print out what eval would evaluate, so I can see how to
compose the string?

Thx for answering again ;-)

SvT


-- 
Who is the ennemy?

mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] eval function

2003-08-23 Thread Tom Rogers
Hi,

Saturday, August 23, 2003, 10:01:54 PM, you wrote:
MW Hallo Tom,

MW am Samstag, 23. August 2003 um 05:14 hast Du Folgendes gekritzelt:

TR This should do it:

TR eval('${content.$databasepagename}[$i]();');

MW I'm afraid to say it, but it does not :-(

MW Yesterday I was also trying to find some manual pages about eval()
MW which would explain me the syntax. The example in the PHP-Manual is
MW not meaning much to me.

MW How can I print out what eval would evaluate, so I can see how to
MW compose the string?

MW Thx for answering again ;-)

MW SvT

This works for me, what error message do you get? Make sure you use
single quotes in the eval otherwise the string will get substituted
before eval gets a look at it.

?php
$contentarray = array(1='testpage');
function testpage(){
echo 'Test succceeded br';
}
$i = 1;
$databasepagename = 'array';

eval('${content.$databasepagename}[$i]();');
?

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval function

2003-08-23 Thread Matthias Wulkow
Hallo Tom,

am Samstag, 23. August 2003 um 17:50 hast Du Folgendes gekritzelt:


TR This works for me, what error message do you get? Make sure you use
TR single quotes in the eval otherwise the string will get substituted
TR before eval gets a look at it.

TR ?php
TR $contentarray = array(1='testpage');
TR function testpage(){
TR echo 'Test succceeded br';
TR }
TR $i = 1;
TR $databasepagename = 'array';

TR eval('${content.$databasepagename}[$i]();');
?

That's the error I find in the apache-log. On the screen, I get
nothing but a white page. By the way I have error_reporting(E_ALL);
but I never get errors reported...

PHP Fatal error:  Call to undefined function:  () in 
/usr/local/www/showFunctions.php(77)

Your script is working. But mine not... is it because I'm on a output
buffer? I use ob_start() just before, because the real output is
produced by the function I want to call with the eval method...

Here the part of my script:

$query = SELECT pagename FROM pages;
$result = mysql_query($query);
$a = 0;
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
  $page[$a] = $row[pagename];
  $fct[$a] = $page[$a];
  $fct[$a] = substr($fct[$a],1);
  $fct[$a] = str_replace(.php, , $fct[$a]);
  $fct[$a] = ucfirst($fct[$a]);
  $a++;
}
mysql_free_result($result);

ob_start();

for($b = 0; $b  sizeof($fct); $b++){
  if($_SERVER[PHP_SELF] == $page[$b])
eval('${content.$fct}[$b]();');
}

...

The pagename in the database is stored like /about.php so I change
it to About in the while-loop.

The eval method is there to replace my actual code (which is static):
if($_SERVER[PHP_SELF] == /login.php)
  contentLogin();
if($_SERVER[PHP_SELF] == /logout.php)
  contentLogout();

...

Using the if-cascade, it is working, for you to know that the
mistake is definitly in the eval()-method...

Thx for your time...

SvT


-- 
Who is the ennemy?

mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval function

2003-08-23 Thread Matthias Wulkow
Hallo Tom,

am Samstag, 23. August 2003 um 17:50 hast Du Folgendes gekritzelt:

TR Hi,

TR Saturday, August 23, 2003, 10:01:54 PM, you wrote:
MW Hallo Tom,

MW am Samstag, 23. August 2003 um 05:14 hast Du Folgendes gekritzelt:

TR This should do it:

TR eval('${content.$databasepagename}[$i]();');

MW I'm afraid to say it, but it does not :-(

MW Yesterday I was also trying to find some manual pages about eval()
MW which would explain me the syntax. The example in the PHP-Manual is
MW not meaning much to me.

MW How can I print out what eval would evaluate, so I can see how to
MW compose the string?

MW Thx for answering again ;-)

MW SvT

TR This works for me, what error message do you get? Make sure you use
TR single quotes in the eval otherwise the string will get substituted
TR before eval gets a look at it.

TR ?php
TR $contentarray = array(1='testpage');
TR function testpage(){
TR echo 'Test succceeded br';
TR }
TR $i = 1;
TR $databasepagename = 'array';

TR eval('${content.$databasepagename}[$i]();');
?

Sorry, I got it to show errors...

here: (it's almost the same than in apache-log)

Notice: Undefined variable: contentArray in /usr/local/www/showFunctions.php(77) : 
eval()'d code on line 1

Fatal error: Call to undefined function: () in /usr/local/www/showFunctions.php(77) : 
eval()'d code on line 1

SvT

-- 
Who is the ennemy?

mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] eval function

2003-08-23 Thread Tom Rogers
Hi,

Sunday, August 24, 2003, 2:32:01 AM, you wrote:

MW That's the error I find in the apache-log. On the screen, I get
MW nothing but a white page. By the way I have error_reporting(E_ALL);
MW but I never get errors reported...

MW PHP Fatal error:  Call to undefined function:  () in 
/usr/local/www/showFunctions.php(77)

MW Your script is working. But mine not... is it because I'm on a output
MW buffer? I use ob_start() just before, because the real output is
MW produced by the function I want to call with the eval method...

MW Here the part of my script:

MW $query = SELECT pagename FROM pages;
MW $result = mysql_query($query);
MW $a = 0;
MW while($row = mysql_fetch_array($result, MYSQL_BOTH)){
MW   $page[$a] = $row[pagename];
MW   $fct[$a] = $page[$a];
MW   $fct[$a] = substr($fct[$a],1);
MW   $fct[$a] = str_replace(.php, , $fct[$a]);
MW   $fct[$a] = ucfirst($fct[$a]);
MW   $a++;
MW }
MW mysql_free_result($result);

MW ob_start();

MW for($b = 0; $b  sizeof($fct); $b++){
MW   if($_SERVER[PHP_SELF] == $page[$b])
MW eval('${content.$fct}[$b]();');
MW }

MW ...

MW The pagename in the database is stored like /about.php so I change
MW it to About in the while-loop.

MW The eval method is there to replace my actual code (which is static):
MW if($_SERVER[PHP_SELF] == /login.php)
MW   contentLogin();
MW if($_SERVER[PHP_SELF] == /logout.php)
MW   contentLogout();

MW ...

MW Using the if-cascade, it is working, for you to know that the
MW mistake is definitly in the eval()-method...

MW Thx for your time...

MW SvT


MW -- 
MW Who is the ennemy?

MW mailto:[EMAIL PROTECTED]



Ok we have to do it in 2 steps like this:

eval('$fn=content.$fct[$b];$fn();');

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval function

2003-08-22 Thread Matthias Wulkow
Hi php-general,

I have a question about eval();

I'm having multiple pagenames I store in a database. I also have a lot
of functions starting with content and then the name of the pages
taken from the database. Ex: pagenames = about,download functions =
contentAbout(), contentDownload().
Now I would like to have a loop of if to make the decision which
function to use, like:
for($i = 0; $i  sizeof($databasepagename);$i++){
  if($_SERVER[PHP_SELF] == $databasepagename[$i])
eval(content.$databasepagename[$i].(););
}
but that doesn't work...

How could I achieve that? Thanks for answering...

SvT

-- 
Who is the ennemy?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval function

2003-08-22 Thread Tom Rogers
Hi,

Saturday, August 23, 2003, 8:38:32 AM, you wrote:
MW Hi php-general,

MW I have a question about eval();

MW I'm having multiple pagenames I store in a database. I also have a lot
MW of functions starting with content and then the name of the pages
MW taken from the database. Ex: pagenames = about,download functions =
MW contentAbout(), contentDownload().
MW Now I would like to have a loop of if to make the decision which
MW function to use, like:
MW for($i = 0; $i  sizeof($databasepagename);$i++){
MW   if($_SERVER[PHP_SELF] == $databasepagename[$i])
MW eval(content.$databasepagename[$i].(););
MW }
MW but that doesn't work...

MW How could I achieve that? Thanks for answering...

MW SvT

MW -- 
MW Who is the ennemy?

This should do it:

eval('${content.$databasepagename}[$i]();');

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval

2003-08-01 Thread Decapode Azur

Is it possible to put PHP code in eval ?
Or just vars ?


?php

$string = 'The result of ?php $a=2; $b=3; $c=$a+$b; echo $a + $b is $c; 
?';

eval ($string);

?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval

2003-08-01 Thread Adrian
PHP-Code:
eval('?'.$string)

Vars:

eval('$string='.str_replace('','\\',$string).';');



 Is it possible to put PHP code in eval ?
 Or just vars ?


 ?php

 $string = 'The result of ?php $a=2; $b=3; $c=$a+$b; echo $a + $b is $c; 
?';

 eval ($string);

?



-- 
Adrian
mailto:[EMAIL PROTECTED]
www: http://www.planetcoding.net
www: http://www.webskyline.de



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval

2003-08-01 Thread Joona Kulmala
Decapode Azur wrote:

Is it possible to put PHP code in eval ?
Or just vars ?
?php

$string = 'The result of ?php $a=2; $b=3; $c=$a+$b; echo $a + $b is $c; 
?';

eval ($string);

?
It should go like:

[code]

eval('$var = The result of; $a=2; $b=3; $c = $a + $b; $var .= $a + $b is $c;');

[/code]

Just a question, what are you really trying to do?

Cheers, Joona
--
Joona Kulmala [EMAIL PROTECTED]
PHP Finland
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Eval var from query

2003-07-14 Thread Shawn McKenzie
How can I evaluate a var that is from a text field of a database?  Example:

MySQL field `name` = hi my name is $name

In my script I have:

$name = Shawn;

After fetching a query result as an associative array I have the contents of
the `name` field in $data

If I echo $data I get:  hi my name is $name

I would like to get:  hi my name is Shawn

TIA,
Shawn



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Eval var from query

2003-07-14 Thread Marco Tabini
On Mon, 2003-07-14 at 15:03, Shawn McKenzie wrote:
 How can I evaluate a var that is from a text field of a database?  Example:
 

Hi Shawn--

Have you looked at eval?

http://www.php.net/eval.

Cheers,


Marco

-- 
php|architect -- The Magazine for PHP Professionals
NOW AVAILABLE IN PRINT! Get your free copy today at
http://www.phparch.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Eval var from query

2003-07-14 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 20:03,
lines prefixed by '' were originally written by you.
 How can I evaluate a var that is from a text field of a database?
 Example:
 MySQL field `name` = hi my name is $name
 In my script I have:
 $name = Shawn;
 After fetching a query result as an associative array I have the
 contents of
 the `name` field in $data
 If I echo $data I get:  hi my name is $name
 I would like to get:  hi my name is Shawn

Use eval($data)

See http://uk.php.net/eval for more info.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Eval var from query

2003-07-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 20:15,
lines prefixed by '' were originally written by you.
 eval($data)
 returns Parse error: parse error, unexpected T_STRING in
 C:appsapache2htdocstestquery.php(23) : eval()'d code on line 1

What are the exact contents of data?

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Eval or $$ are they the same or is $$ safer

2003-06-11 Thread Jason Lehman
Is $$ the same as eval or is it different and my main question is, is it
safer to use to for processing form data?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Eval or $$ are they the same or is $$ safer

2003-06-11 Thread Leif K-Brooks
Use $$ unless you need to use eval.  Easier to read, faster to process.  
Also safer if you don't validate form data.

Jason Lehman wrote:

Is $$ the same as eval or is it different and my main question is, is it
safer to use to for processing form data?


 

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Eval or $$ are they the same or is $$ safer

2003-06-11 Thread Shawn McKenzie
Can you expand on this?  I haven't found a ref to the $$ except for variable
variables.  $$ What does it do? How is it used?

Thanks!
Shawn

Leif K-Brooks [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Use $$ unless you need to use eval.  Easier to read, faster to process.
 Also safer if you don't validate form data.

 Jason Lehman wrote:

 Is $$ the same as eval or is it different and my main question is, is it
 safer to use to for processing form data?
 
 
 
 
 

 -- 
 The above message is encrypted with double rot13 encoding.  Any
unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Eval or $$ are they the same or is $$ safer

2003-06-11 Thread Leif K-Brooks
$$ is perfectly explained in the variable variables section.

Shawn McKenzie wrote:

Can you expand on this?  I haven't found a ref to the $$ except for variable
variables.  $$ What does it do? How is it used?
Thanks!
Shawn
Leif K-Brooks [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 

Use $$ unless you need to use eval.  Easier to read, faster to process.
Also safer if you don't validate form data.
Jason Lehman wrote:

   

Is $$ the same as eval or is it different and my main question is, is it
safer to use to for processing form data?




 

--
The above message is encrypted with double rot13 encoding.  Any
   

unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.
 

   



 

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] eval error

2003-03-10 Thread Alawi

what problem I want to use eval in my script but its generate this error : 
Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(22) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(22) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4
A { font-style : normal;text-decoration : none;}
this is the cod from line 18

WHILE (!$ALL_TYPES_RS-EOF) {
   //vars
 extract($ALL_TYPES_RS-fields,EXTR_OVERWRITE);
//eval
eval (\$all_types_list .= \$all_types_list\;);
$ALL_TYPES_RS-MoveNext();
}
 $contform = put_sun_in_father(ALL_TYPES, $all_types_list, contform);




-
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

Re: [PHP] eval error

2003-03-10 Thread Marek Kilimajer
try
echo \$all_types_list .= \$all_types_list\;;
there should be a syntax error
Alawi wrote:

what problem I want to use eval in my script but its generate this error : 
Parse error: parse error, unexpected T_LNUMBER in C:\Projects\phpmag\admin\functions\admin_cont.php(22) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in C:\Projects\phpmag\admin\functions\admin_cont.php(22) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4

Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(40) : eval()'d code on line 4
A { font-style : normal;text-decoration : none;}
this is the cod from line 18
   WHILE (!$ALL_TYPES_RS-EOF) {
  //vars
extract($ALL_TYPES_RS-fields,EXTR_OVERWRITE);
   //eval
   eval (\$all_types_list .= \$all_types_list\;);
   $ALL_TYPES_RS-MoveNext();
   }
$contform = put_sun_in_father(ALL_TYPES, $all_types_list, contform);


-
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] eval error

2003-03-10 Thread Chris Hayes
At 12:54 10-3-03, you wrote:

what problem I want to use eval in my script but its generate this error :
Parse error: parse error, unexpected T_LNUMBER in 
C:\Projects\phpmag\admin\functions\admin_cont.php(22) : eval()'d code on line 4
   eval (\$all_types_list .= \$all_types_list\;);


For those who do not know what all the CAPITALIZED secret words in error 
messages mean: i found a list of them on 
http://www.zend.com/manual/tokens.php. A T_LNUMBER is an integer.

I __suppose__ that $all_types_list contains a number, maybe 144, and while 
you mean to do
$all_types_list.=144;
the eval function somehow evaluates
$all_types_list.=144;

And .= expects a string on the right side, not an integer.

Maybe someone who is more experienced with eval() can shed more light on this.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] eval challenge

2003-03-04 Thread neko
- define a string that has a function call in it (that returns a string)
that at the time of declaration is not in scope, eg

$str = this is the name : \$node-getName(); // $node is _not_ defined
currently, so we can't escape out



then, later on in the code, this string will be passed to a function that
has $node in scope, and that's when I want to eval the string to replace the
value.

$node = new Node($argwhatever);
eval(\$str=\$str\;); // $node is now in scope, so I'd really like
$node-getName to return something meaningful

Anyone able to solve this one? Yesterday I could achieve most other
requirements with eval, but this one has me stumped.

cheers,
neko



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval challenge

2003-03-04 Thread Dan Hardiker
 - define a string that has a function call in it (that returns a string)
 that at the time of declaration is not in scope, eg

 $str = this is the name : \$node-getName(); // $node is _not_ defined
 currently, so we can't escape out

Ya have 2 options really (from my perspective):

1. Place in jump out's

If you know your evaling routine is using 's then use them to break out of
the parser. Firstly - this is bad coding - as if you can break out, then
so can the rest of the data in the string. If you insist on this method,
on any external data check for the break out char and escape it -
otherwise you have a major security hole.

$str = text here '.\$node-getName().'more text maybe;
eval(\$str = '$str';);

NOTE: there is no ' at the start or end of the string - this is important.

2. Build a string parser and use tagging... easiest done in XML imho

$str = some text here exec$node-getName()/exec;
Then go through the string before the eval executing everything between
exec tags (be security concious for heavens sake - can be dangerous if not
strictly checked) and replace the command with the response.

I can provide sample code for either options ... but would rather not mock
up a test bed if its not gonna get used ;)

PS: Im guessing your building dynamic templates ... have you had a look
into smarty? http://smarty.php.net/


-- 
Dan Hardiker [EMAIL PROTECTED]
ADAM Software  Systems Engineer
First Creative



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval challenge

2003-03-04 Thread neko
Thanks for your time, Dan.

Currently, I'm using defined tags for replacing info from my CMS, eg:

$str = ofa-core:siteMapLink/

Then I have a function that has all the objects in scope, and can perform
the necessary replacements.

I am prototyping some stuff with smarty, but so far have yet to see how it
benefits over my current implementation. I don't have to to worry about
non-technical persons building/maintaining the site, so I'd rather stick
with include() to build my pages from templates/blocks/content.

As I learn more about smarty, I might use it to power the presentation layer
of my CMS, but only when I can see a long-term benefit from using it. My cms
makes use of presentation logic components, which you supply microtemplates
to  in order to produce the final output. These components can reside within
templates, so currently my html redundancy is minimal.

cheers,
neko



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval challenge

2003-03-04 Thread Dan Hardiker
 Currently, I'm using defined tags for replacing info from my CMS, eg:

 $str = ofa-core:siteMapLink/

 Then I have a function that has all the objects in scope, and can
 perform the necessary replacements.

ok ... what would ofa-core:siteMapLink/ represent?
The output of $ofa-core-siteMapLink();?

If your using XML throughout - have you looked at XSLT transformations?


-- 
Dan Hardiker [EMAIL PROTECTED]
ADAM Software  Systems Engineer
First Creative



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval challenge

2003-03-04 Thread neko
 ok ... what would ofa-core:siteMapLink/ represent?
 The output of $ofa-core-siteMapLink();?

 If your using XML throughout - have you looked at XSLT transformations?

It's just a symbolic name - the output is created from a few different
objects within the CMS, but it was such a commonly used set of data requests
that I make a tag up to handle them all at once, to make it a bit cleaner.

XSL/XSLT is on my to prototype list ;)

neko



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval help

2003-03-03 Thread neko
Hi guys,

My current task involves passing a string into a function that is able to
reference variables defined within that function for the final output. The
idea is that a function iterates through objects and eval's the string so
that the objects data (name etc) is substituted in the string.

Currently I have something like this:

$someVar = brtesting for node - wootah, \$evalTestArr[TAG_PAGENAME]


then in some other function that gets passed this string
...

$evalTestArr[TAG_PAGENAME] = hello anna marie gooberfish!;
$str = $someVar;
eval(\$str=\$str\;);

if I echo it out, the substitution is not done.

any thoughts? I'm reading through
http://www.php.net/manual/en/function.eval.php but yet to be inspired.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eval help

2003-03-03 Thread Ernest E Vogelsinger
At 14:47 03.03.2003, neko said:
[snip]
$someVar = brtesting for node - wootah, \$evalTestArr[TAG_PAGENAME]


then in some other function that gets passed this string
...

$evalTestArr[TAG_PAGENAME] = hello anna marie gooberfish!;
$str = $someVar;
eval(\$str=\$str\;);

if I echo it out, the substitution is not done.
[snip] 

try
$someVar = brtesting for node - wootah, \{\$evalTestArr[TAG_PAGENAME]\}

Array derefs within quoted strings must be enclosed in curly quotes.


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] eval problem

2002-07-02 Thread Greg Wineman

Hello,

Could someone offer some insight on eval(); I am fairly new at this.

I would like to evaluate numerous variables from a form submission with a
loop, but I can;t even get on to work:

I.e.

He are the variables from my form

wins_1=7
losses_1=0
sort_1=1
wins_2=7
losses_2=4
sort_2=2
wins_3=7
losses_3=4
sort_3=3

I am trying to evaluate the values based on a loop.  Here's my current
method

$counter=1;
$wins=eval(\$wins_.$counter);

$wins should return 7 in this example.  Where am I going wrong?

Any help would be appreciated.

Thanks,
Greg



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval problem

2002-07-02 Thread Analysis Solutions

On Tue, Jul 02, 2002 at 10:19:59PM -0400, Greg Wineman wrote:
 
 He are the variables from my form
 
 wins_1=7
 losses_1=0
 sort_1=1
 wins_2=7
 losses_2=4
 sort_2=2
 wins_3=7
 losses_3=4
 sort_3=3
 
 $counter=1;
 $wins=eval(\$wins_.$counter);

eval() is overkill and can be dangerous.

I'd use variable variables instead:

$wins = 0;
for ($counter=1; $counter=3; $counter++) {
   $var = $wins_$counter;
   $wins = $wins + $$var;
}

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval problem

2002-07-02 Thread Analysis Solutions

On Tue, Jul 02, 2002 at 10:45:27PM -0400, Analysis  Solutions wrote:

$var = $wins_$counter;

Oops.  Forgot to escape the $:

$var = \$wins_$counter;

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval problem

2002-07-02 Thread Greg Wineman

This doesn't seem to work. Here's my demo.

?
$wins_1=7;
$losses_1=0;
$sort_1=1;
$wins_2=4;
$losses_2=4;
$sort_2=2;
$wins_3=3;
$losses_3=4;
$sort_3=3;

$wins = 0;
for ($counter=1; $counter=3; $counter++) {
   $var = $wins_$counter;
   $wins = $wins + $$var;
   echo($wins);
}
?

This returns 000, it should return 743




Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Jul 02, 2002 at 10:19:59PM -0400, Greg Wineman wrote:
 
  He are the variables from my form
 
  wins_1=7
  losses_1=0
  sort_1=1
  wins_2=7
  losses_2=4
  sort_2=2
  wins_3=7
  losses_3=4
  sort_3=3
 
  $counter=1;
  $wins=eval(\$wins_.$counter);

 eval() is overkill and can be dangerous.

 I'd use variable variables instead:

 $wins = 0;
 for ($counter=1; $counter=3; $counter++) {
$var = $wins_$counter;
$wins = $wins + $$var;
 }

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval problem

2002-07-02 Thread Greg Wineman

hmm... I must be doing something wrong.  This is still returning 000

?
$wins_1=7;
$losses_1=0;
$sort_1=1;
$wins_2=4;
$losses_2=4;
$sort_2=2;
$wins_3=3;
$losses_3=4;
$sort_3=3;

$wins = 0;
for ($counter=1; $counter=3; $counter++) {
   $var = \$wins_$counter;
   $wins = $wins + $$var;
   echo($wins);
}
?




Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Jul 02, 2002 at 10:45:27PM -0400, Analysis  Solutions wrote:

 $var = $wins_$counter;

 Oops.  Forgot to escape the $:

 $var = \$wins_$counter;

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval problem

2002-07-02 Thread Analysis Solutions

On Tue, Jul 02, 2002 at 11:19:22PM -0400, Analysis  Solutions wrote:
 
 Oops.  Forgot to escape the $:
 
 $var = \$wins_$counter;

Oops.  Forgot my promise to myself to always test things before posting.  
I had a sinking feeling my initial posting would come back to haunt me, 
but I JUST DIDN'T CARE!!! :)  Anyway, here's how this line should read:

 $var = wins_$counter;

Sorry for the confusion and multiple posts.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval problem

2002-07-02 Thread Greg Wineman

You da man. Thanks


Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Jul 02, 2002 at 11:19:22PM -0400, Analysis  Solutions wrote:
 
  Oops.  Forgot to escape the $:
 
  $var = \$wins_$counter;

 Oops.  Forgot my promise to myself to always test things before posting.
 I had a sinking feeling my initial posting would come back to haunt me,
 but I JUST DIDN'T CARE!!! :)  Anyway, here's how this line should read:

  $var = wins_$counter;

 Sorry for the confusion and multiple posts.

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] eval()

2002-05-20 Thread jtjohnston

I know I'm not doing this right, but ..

What I want to do is display the value of $q1 through $q3.
How? I can't get eval() to do it, can I?

for ($i = 1; $i = 3; $i++)
{
$x= eval (\$q.$i);
echob$x/b\n;
echobrinput type=\hidden\ name=\a.$i.\ value=\\\n;
}

John


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval()

2002-05-20 Thread Miguel Cruz

On Mon, 20 May 2002, jtjohnston wrote:
 I know I'm not doing this right, but ..
 
 What I want to do is display the value of $q1 through $q3.
 How? I can't get eval() to do it, can I?
 
 for ($i = 1; $i = 3; $i++)
 {
 $x= eval (\$q.$i);
 echob$x/b\n;
 echobrinput type=\hidden\ name=\a.$i.\ value=\\\n;
 }

eval() is for running code, not parsing strings.

Try something like:

  for ($i = 1; $i = 3; $i++)
  {
$var = q$i;
print brinput type='hidden' name='{$$var}'\n;
  }

Or use arrays.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval()

2002-05-20 Thread Bogdan Stancescu

for ($i = 1; $i = 3; $i++) {
$x= $q$i;
$val=$$x;
echob$val/b\n;
echobrinput type=\hidden\ name=\a.$i.\ value=\\\n;
}



jtjohnston wrote:

I know I'm not doing this right, but ..

What I want to do is display the value of $q1 through $q3.
How? I can't get eval() to do it, can I?

for ($i = 1; $i = 3; $i++)
{
$x= eval (\$q.$i);
echob$x/b\n;
echobrinput type=\hidden\ name=\a.$i.\ value=\\\n;
}

John






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] eval()

2002-05-20 Thread Bogdan Stancescu

Sorry, please change line 2 with $x=q$i.

Bogdan

Bogdan Stancescu wrote:

 for ($i = 1; $i = 3; $i++) {
 $x= $q$i;
 $val=$$x;
 echob$val/b\n;
 echobrinput type=\hidden\ name=\a.$i.\ value=\\\n;
 }



 jtjohnston wrote:

 I know I'm not doing this right, but ..

 What I want to do is display the value of $q1 through $q3.
 How? I can't get eval() to do it, can I?

 for ($i = 1; $i = 3; $i++)
 {
 $x= eval (\$q.$i);
 echob$x/b\n;
 echobrinput type=\hidden\ name=\a.$i.\ value=\\\n;
 }

 John










-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] eval on php embedded html

2002-01-24 Thread DigitalKoala

hi folks,

i'm having a problem using eval.

i have some html code interdispersed with php code (proper statement not
just variables) in a database.  when i fetch the code and display it using :

$reg_adv_html=addslashes($reg_adv_html);
eval(\$reg_adv_html = \$reg_adv_html\;);
$reg_adv_html=stripslashes($reg_adv_html);

  print $reg_adv_html;

the variables work (their values are substitued), but my condtional staments
don't work.

example from $reg_adv_html :

TD valign=centerinput type=radio name=radiobutton1 value=reg1 ?
if ($radiobutton1==on) { print selected; ? /TD


can someone tell me if i have to remove the ? ? tags from the html?

thanks very much!

dk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eval on php embedded html

2002-01-24 Thread Atanas Vassilev

 So, either:

 ? if ($radiobutton1 == on) { print selected; } ?

 Or

 ? if ($radiobutton1 == on) print selected; ?

I found it very convenient for in-html coding to use the following
structure:

input blabla bla ? echo($radiobutton1 == on ? selected : );?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] eval()

2002-01-20 Thread Kunal Jhunjhunwala

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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] eval on a form

2001-12-09 Thread Paul Roberts

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 checked if the
variable is present.

any ideas


Paul Roberts
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eval on a form

2001-12-09 Thread Diego Pérez



 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 checked if the
 variable is present.

 any ideas

Hi Paul:

I think that you can use JavaScript or VBScript to check the variable
and the checkbox.

When the user click on the send Button, you can call a fuction that
evaluate all that you need. When the evaluation is OK you can send the data
to another page in parameters.

You can use window.open in javascript.

I don't know if i can help you with this notes.

Bye.

Diego


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Eval()??? A variables contents?

2001-11-09 Thread Christopher Raymond




PHP Gurus:

I have one for you. I'm sure there is a simple solution, but I'm having
difficulty finding it.


Let's say I have:

$content = ?PHP Query_Database( $category );?;


If I use ?PHP echo $content; ?, it doesn't evaluate that content. What am
I doing wrong here?


Is there an equivalent to JavaScript's eval($commands) function?


TIA,

Christopher Raymond


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Eval()??? A variables contents?

2001-11-09 Thread Kurt Lieber

On Friday 09 November 2001 11:51 am, Christopher Raymond wrote:
 Let's say I have:

 $content = ?PHP Query_Database( $category );?;


 If I use ?PHP echo $content; ?, it doesn't evaluate that content. What am
 I doing wrong here?

What you're doing doesn't make any sense.  If it were to work, it would look 
like the following:

?PHP ?PHP Query_Database( $category );? ; ?,

or something similar.  I think what you want to do is:
?php
  $content = query_database($category);
  echo $content;
?

that's using psuedo-code, of course.  You'll want to substitute correct php 
syntax for returning database results.

--kurt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Eval()??? A variables contents?

2001-11-09 Thread Chris Hobbs

I just asked a similar question yesterday. The answer is, conveniently
enough, eval().

One trick from the php.net page on the function is to do somehting like
this:

$content = ?PHP Query_Database( $category );?;
echo eval (?$content);


Christopher Raymond wrote:
 
 PHP Gurus:
 
 I have one for you. I'm sure there is a simple solution, but I'm having
 difficulty finding it.
 
 Let's say I have:
 
 $content = ?PHP Query_Database( $category );?;
 
 If I use ?PHP echo $content; ?, it doesn't evaluate that content. What am
 I doing wrong here?
 
 Is there an equivalent to JavaScript's eval($commands) function?
 
 TIA,
 
 Christopher Raymond
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Chris Hobbs   Silver Valley Unified School District
Head geek:  Technology Services Coordinator
webmaster:   http://www.silvervalley.k12.ca.us/~chobbs/
postmaster:   [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Eval()??? A variables contents?

2001-11-09 Thread Christopher Raymond

on 11/9/01 2:01 PM, Kurt Lieber at [EMAIL PROTECTED] wrote:

 What you're doing doesn't make any sense.  If it were to work, it would look
 like the following:
 
 ?PHP ?PHP Query_Database( $category );? ; ?,
 
 or something similar.  I think what you want to do is:
 ?php
 $content = query_database($category);
 echo $content;
 ?
 
 that's using psuedo-code, of course.  You'll want to substitute correct php
 syntax for returning database results.




Kurt:

I understand where you are coming from, and I appreciate your answer.
However, I'm trying to get PHP to parse commands that are stored in a
variable because I'm passing those commands to a function. Inside the
function, it needs to evaluate the commands stored in the variable.

Does you solution solve that or does my description clarify my problem
better?


Thanks,

Christopher


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Eval()??? A variables contents?

2001-11-09 Thread Johnson, Kirk

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

Kirk


 -Original Message-
 From: Christopher Raymond [mailto:[EMAIL PROTECTED]]
 Sent: Friday, November 09, 2001 1:11 PM
 To: PHP List
 Subject: Re: [PHP] Eval()??? A variables contents?
 
 
 on 11/9/01 2:01 PM, Kurt Lieber at [EMAIL PROTECTED] wrote:
 
  What you're doing doesn't make any sense.  If it were to 
 work, it would look
  like the following:
  
  ?PHP ?PHP Query_Database( $category );? ; ?,
  
  or something similar.  I think what you want to do is:
  ?php
  $content = query_database($category);
  echo $content;
  ?
  
  that's using psuedo-code, of course.  You'll want to 
 substitute correct php
  syntax for returning database results.
 
 
 
 
 Kurt:
 
 I understand where you are coming from, and I appreciate your answer.
 However, I'm trying to get PHP to parse commands that are stored in a
 variable because I'm passing those commands to a function. Inside the
 function, it needs to evaluate the commands stored in the variable.
 
 Does you solution solve that or does my description clarify my problem
 better?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Eval error

2001-08-16 Thread Pavel Jartsev

Felipe Coury wrote:
 
 Hi,
 
 I am a beginner in PHP and I am trying to do the following: I have a form in
 a page that has 3 fields: email_1, email_2 and email_3. I am trying to send
 e-mail to those people, if the fields are filled. Relevant part of code:
 
 ?php
 for ($i = 1; $i = 6; $i++) {
 $eval = '\$email = \$email_' + $i + ';';
 eval( $eval );
 echo $email;
 }
 ?
 
 The code complains about an error in line eval( $eval );:
 
 Parse error: parse error in
 /home/httpd/htdocs/hthcombr/cgi-local/envia.php(19) : eval()'d code on line
 1
 
 Can anyone please help me?
 

Use arrays, it's much easier. Set name of fields like this: email[0],
email[1] and email[2].
Now after submitting the form you have array $email. And for-loop will
be:
?
for($i=0; $i  sizeof($email); $i++) {
 echo $email[$i];
}
?

Hope this helps.

-- 
Pavel a.k.a. Papi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Eval error

2001-08-15 Thread Felipe Coury

Hi,

I am a beginner in PHP and I am trying to do the following: I have a form in
a page that has 3 fields: email_1, email_2 and email_3. I am trying to send
e-mail to those people, if the fields are filled. Relevant part of code:

?php
for ($i = 1; $i = 6; $i++) {
$eval = '\$email = \$email_' + $i + ';';
eval( $eval );
echo $email;
}
?

The code complains about an error in line eval( $eval );:

Parse error: parse error in
/home/httpd/htdocs/hthcombr/cgi-local/envia.php(19) : eval()'d code on line
1

Can anyone please help me?

Regards,

Felipe Coury


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Eval error

2001-08-15 Thread Mark Maggelet

lots of things:

1) variables in single-quoted strings aren't evaluated so you don't
need to escape the $ in $email

2) php uses . not + for concatenation.

3) try it like this:
eval('$email = $email_'.$i.';');
or
eval(\$email = \$email_$i;);

4) you can save yourself the trouble by using arrays as field names:
input name=email[1]

5) RTFM! that's what its there for.



On Wed, 15 Aug 2001 15:15:09 -0300, Felipe Coury
([EMAIL PROTECTED]) wrote:
Hi,

I am a beginner in PHP and I am trying to do the following: I have a
form in
a page that has 3 fields: email_1, email_2 and email_3. I am trying
to send
e-mail to those people, if the fields are filled. Relevant part of
code:
?php
for ($i = 1; $i = 6; $i++) {
$eval = '\$email = \$email_' + $i + ';';
eval( $eval );
echo $email;
}
?

The code complains about an error in line eval( $eval );:

Parse error: parse error in
/home/httpd/htdocs/hthcombr/cgi-local/envia.php(19) : eval()'d code
on line
1

Can anyone please help me?

Regards,

Felipe Coury


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: php-list-
[EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] eval() to string???

2001-01-24 Thread [ rswfire ]

I want to evaluate some PHP code to a string.  How can I do this?

$php_code = "echo 'hello';"

I would like to evaluate the code to "hello" in another string...



AW: [PHP] eval() to string???

2001-01-24 Thread Thomas Weber

try

eval("\$php_code;");

-Ursprngliche Nachricht-
Von: [ rswfire ] [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 24. Januar 2001 15:36
An: [EMAIL PROTECTED]
Betreff: [PHP] eval() to string???


I want to evaluate some PHP code to a string.  How can I do this?

$php_code = "echo 'hello';"

I would like to evaluate the code to "hello" in another string...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




AW: [PHP] eval() to string???

2001-01-24 Thread Thomas Weber


okay, i see

here is an example:

$php_code = "$foo + $bar";
eval("\$var = \"$php_code\";);

now in $var there should be the eval of $foo + $bar


-Ursprngliche Nachricht-
Von: Robert S. White [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 24. Januar 2001 16:20
An: [EMAIL PROTECTED]
Betreff: Re: [PHP] eval() to string???


How is this going to help me?

I want to evaluate the code in $php_code to *another* string...


- Original Message -
From: Thomas Weber 
To: Php-General 
Sent: Wednesday, January 24, 2001 10:14 AM
Subject: AW: [PHP] eval() to string???


 try

 eval("\$php_code;");

 -Ursprngliche Nachricht-
 Von: [ rswfire ] [mailto:[EMAIL PROTECTED]]
 Gesendet: Mittwoch, 24. Januar 2001 15:36
 An: [EMAIL PROTECTED]
 Betreff: [PHP] eval() to string???


 I want to evaluate some PHP code to a string.  How can I do this?

 $php_code = "echo 'hello';"

 I would like to evaluate the code to "hello" in another string...


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] eval() to string???

2001-01-24 Thread indrek siitan

Hi,

 I want to evaluate the code in $php_code to *another* string...

you have to do it through output buffering:

  ob_start();
  eval($php_code);
  $another_string=ob_get_contents();
  ob_end_clean();


Rgds,
  Tfr

  --== [EMAIL PROTECTED] == http://tfr.cafe.ee/ == +372-50-17621 ==-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: AW: [PHP] eval() to string???

2001-01-24 Thread Steve Edberg

-Ursprngliche Nachricht-
Von: Robert S. White [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 24. Januar 2001 16:20
An: [EMAIL PROTECTED]
Betreff: Re: [PHP] eval() to string???


How is this going to help me?

I want to evaluate the code in $php_code to *another* string...



From

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

"A return statement will terminate the evaluation of the string
immediatley. In PHP 4 you may use return to return a value that will
become the result of the eval() function while in PHP 3 eval() was of
type void and did never return anything."

So, if you're using PHP4, just ensure that there is a return
in$php_code that returns the desired value:

$thing = eval($php_code);

It's helpful to read the notes at the above URL - escaping things
correctly for eval() can be tricky...


- steve


- Original Message -
From: Thomas Weber 
To: Php-General 
Sent: Wednesday, January 24, 2001 10:14 AM
Subject: AW: [PHP] eval() to string???


  try

  eval("\$php_code;");

  -Ursprngliche Nachricht-
  Von: [ rswfire ] [mailto:[EMAIL PROTECTED]]
  Gesendet: Mittwoch, 24. Januar 2001 15:36
  An: [EMAIL PROTECTED]
  Betreff: [PHP] eval() to string???


  I want to evaluate some PHP code to a string.  How can I do this?

  $php_code = "echo 'hello';"

  I would like to evaluate the code to "hello" in another string...


   --

--
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] eval() function

2001-01-14 Thread Adam Powell


Hi, in my application I am making a lot of use of the eval() function,
however I was wondering if this is going to cause any extra load.  Does it
do anything like load in the PHP engine again or anything?  We just added it
in and the load on our web servers went up... so I was wondering if I should
be aware of anything.

Thanks,
Adam


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eval() function

2001-01-14 Thread Rasmus Lerdorf

Yes, eval() is expensive.

On Sun, 14 Jan 2001, Adam Powell wrote:


 Hi, in my application I am making a lot of use of the eval() function,
 however I was wondering if this is going to cause any extra load.  Does it
 do anything like load in the PHP engine again or anything?  We just added it
 in and the load on our web servers went up... so I was wondering if I should
 be aware of anything.

 Thanks,
 Adam


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]