note 46206 deleted from function.eval by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 02 Oct 2004 16:57:56 +0000 |
| Subject: | note 46206 deleted from function.eval by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77752@lists.php.net to get a copy of this message | ||
Note Submitter: Dernassi
----
Many asked me some precisions on the way
a caller script should call the function "evaluer.php".
Here is an example with some PHP functions:
*************************************
<?php
function evaluer($chaine)
{
$valeur = '$valeur=' . $chaine;
eval("$valeur");
return ($valeur);
}
?>
#-------------------------------------------
# Example: you must add "require" or "include"
#-------------------------------------------
<?php
include ("evaluer.php");
#****************
$chaine = 'strlen("PHP is powerful");';
$valeur = evaluer($chaine);
echo "valeur=$valeur <br>\n";
$chaine = 'substr("What a wonderful world is PHP",7,8);';
$valeur = evaluer($chaine);
echo "valeur=$valeur <br>\n";
$chaine = 'strpos("What a wonderful world is PHP","wonder");';
$valeur = evaluer($chaine);
echo "valeur=$valeur <br>\n";
?>
This should output the following result directly to the browser:
valeur=15
valeur=wonderfu
valeur=7
NB. Please read the PHP manual before contacting me.
The PHP manual is a good source full of information.
Again thanks to all contributors.
By: M. Dernassi,
lamp@dernassi.com
http://dernassi.com/