eval stuff (was Re: [thelist] testing for empty in javascript or vbscript)

Shashank Tripathi sub at shanx.com
Tue Jul 16 01:04:01 CDT 2002


Thanks for the wonderful info Jeff, but I guess the mandate of eval() at the
serverside, if available, may be a little different.

In PHP for instance, eval() will allow me to replace a variable in a string
very easily. The only alternative would be to manually replace a string
value, which is not a variable. e.g.,

WITH EVAL

    // In messages.inc file
    $message001 = "Something before $variable and something after.";

    // In the code..
    include "messages.inc" ;
    $variable = "testing";
    eval ("\$message001 = \"$message001\";");


WITHOUT EVAL

    // In messages.inc file
    $message001 = "Something before _  and something after.";

    // In the code..we need to replace that underscore with a value
    include "messages.inc" ;
    $variable = "testing";
    $message001 = str_replace("_", $variable, $message001);


AFAIK, both will perform at the same speed. It is a subjective issue which
one a coder likes in terms of maintainability..

Appreciate your JS discussion though, thanks!

Cheers,
Shanx


Shashank Tripathi
www.shanx.com






More information about the thelist mailing list