Home >Backend Development >PHP Tutorial >Introduction to the use of php eval() function_PHP tutorial
We PHP programmers may all use the eval() function to do some operations. Many hackers use this function to make a fuss. They can directly accept the data submitted by the user and execute it. This sentence will I won’t scare you. Let me introduce the usage of eval() function.
If no return statement is called in the code string, NULL is returned. If there are parsing errors in the code, the eval() function returns false.
Grammar
eval(phpcode)
phpcode must specify the PHP code to be calculated.
Example
The code is as follows
|
Copy code
|
||||||||||||
$string = 'cup'; $name = 'coffee'; $str = 'This $string contains $name. ';
echo $str;
This $string contains $name. This cup contains coffee.
Note that eval() is after the variable is assigned a value, and then executed
|