Ask the common sense question of PHP echo and $ string

Source: Internet
Author: User
Issue 1: Found in SQL statements can take $ number, such as $sql= "select * from table where id= $id"; When was this $id parsed?
The question 2:echo is the PHP essential Debug statement, under what circumstances can echo not play the role? Like in class, there's????


Reply to discussion (solution)

$sql = "SELECT * from table where id= $id";
The $id in the right string is parsed when the $sql to the left is assigned a value.

The main function of ECHO is to output the result of the operation, not debug
While debugging, you can use it to print some intermediate quantities to determine how the program is running.
The main debugging functions provided by PHP are:
Var_dump used to observe the type and value of a variable
Debug_zval_dump used to observe the reference of a variable
Debug_backtrace generates a backtracking that is used to observe the invocation of a function (method)

Learn about the 2 debug functions upstairs ...
PHP if the string in double quotation marks, the runtime will parse the variables and special symbols such as \ r \ n line-up and so on, the single quotation mark is not this function.

1. When the right character of a variable is enclosed in double quotation marks, you can parse the $ variable, if it is in single quotation marks. $str. "' Processing.
2.echo is used for output variables, debug please use Var_dump

  • 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.