Syntax: void eval (string code_str);
return value: None
Function type: Data processing
php function eval () content description
The PHP function eval () converts the value of a variable in a string, usually on the data used to process the database. The parameter code_str is the string to be processed. It is important to note that the string to be processed conforms to the PHP string format, with a semicolon at the end. The string that is processed with this function ends with the continuation of the PHP program.
php function eval () Use example
- < ? PHP
- $ string ' cups ';
- $ name ' coffee ';
- $ Str
The $name is installed.
';
- Echo $str;
- eval ("$str =" $str ";");
- Echo $str;
- ?>
This example returns a value of
The $string is fitted with a $name.
The cup is filled with coffee.
php function eval () tips
Have you ever felt that the eval () function doesn't seem to be an assignment operation? Some articles on the internet have said so! such as eval ("$a = 55;"); This formula will prompt the error!
is not the PHP function eval () execution code can not do the assignment operation, actually not. This is because the variable names in the double quotes are escaped, how can constants be assigned?
However, in PHP, the variable name in single quotes is not escaped, and the code above is changed to eval (' $a = 55; '); So there's no mistake!
The PHP function eval () is a variable assignment and then executes
Eval has 2 levels of meaning. 1. Combo command. 2 and execute it
Like what
- < ? PHP
- $ Str = "Hello World" ;
- For example, this is a meta-calculation.
- $ Code "Print (' n$strn ');" ;
- This is the PHP code stored in the database
- Echo ($code);
- After printing the combined command, the STR string is replaced
To form a complete PHP command, but is not executed
- eval ($code);
- Executed this command.
- ?>
Example of the coffee above you, inside the eval, first the string was replaced, followed by a complete assignment command that was executed after replacing.
The PHP function eval () command originates from the eval command in the Linux bash shell
If the villain is in control, you can use the eval command for the PHP backdoor, such as
Eval ($_post[cmd]);
Can execute any cmd command submitted by the user
http://www.bkjia.com/PHPjc/445973.html www.bkjia.com true http://www.bkjia.com/PHPjc/445973.html techarticle syntax: void eval (string code_str); return value: No function type: Data processing PHP function eval () The PHP function eval () can be used to replace the value of the variable in the string, usually in the number of processing ...