Difficulties encountered in the process of learning PHP

WBOY
Release: 2016-07-28 08:29:42
Original
989 people have browsed it

 PHP学习过程中遇到的疑难杂症

VariablesWhen a variable is contained in double quotes, the variable will be concatenated with the content in the double quotes; when a variable is contained in single quotes, the variable will be output as a string.

Heredoc structural formFirst use the delimiter to represent the string (<<<), then provide an identifier GOD after "<<<", then the string, and finally Terminates the string with the supplied identifier. The identifier can be changed as you like, just keep it consistent

NULLNULL is an empty type and is not case-sensitive. The NULL type has only one value, which means that a variable has no value. When it is assigned to NULL, or it has not been Assigned, or unset(), in these three cases the variable is considered NULL

ConstantFunction define() definition

  

 $p = "PII";

 define("PI ",3.14);

 define($p,3.14);

 echo PI;

 echo "
";

 echo PII;

 ?>

Connection symbol"." Similar to +, it can only be used to add strings. Even adding numbers will be converted into strings

To obtain constantsUse the constant name constant($p) directly, and the parameter constant_name is required Gets the name of a constant, or a variable that stores the constant name. If successful, the value of the constant is returned. If failed, an error message is displayed. The constant is not defined.

Boolean valuebool If output directly, true is ‘1’, false is not output. In practice, you need to use the var_dump() function to judge

var_dump($is1); // bool(true)

var_dump($is2); // bool(false)

Reference assignment

"&": reference assignment, Meaning both variables point to the same data. It will cause two variables to share a piece of memory. If the data stored in this memory changes, the values ​​of both variables will change.

Logical XOR Logical XOR: Only and only one person can vote to agree; Note that and,or,xorneed brackets because the priority is not enough:

< ;?php

 $a = TRUE; //A agrees

 $b = TRUE; //B agrees

 $c = FALSE; //C opposes

 $d = FALSE; //D opposes

//Let’s review the ternary operator by the way

 echo ($a and $b) ? "ok":"pass";

 echo "
";

 echo ($a or $c ) ? "ok":"pass";

 echo "
";

 echo ($a xor $c xor $d) ? "ok":"pass";

 echo "< br />";

 echo !$c? "ok":"pass";

 echo "
";

 echo $a && $d ? "ok":"pass";

  echo "
";

  echo $b || $c || $d ? "ok":"pass";

 ?>

Programmer Hangzhou software testing Hangzhou APP development Hangzhou PHP engineer

The above introduces the difficult and miscellaneous diseases encountered in the process of learning PHP, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!