Today's Lesson: PHP 3-Day Foundation Consolidation video Tutorial "Yan 18"
1.php Error Reporting settings
/*php script error, divided into multiple levels, such as fatal error, notice (reminder), warning (warning), n multilevel how to conveniently set the error level PHP has different levels of level, with numbers to indicate such as 1 e_error (integer) Fatal run-time error. Such errors are generally unrecoverable situations, such as problems caused by memory allocations. The result is that the script terminates and no longer continues to run. 2 e_warning (integer) Run-time warning (non-fatal error). Only the prompt is given, but the script does not terminate the run. 4, 8, 16, 32...0000 00010000 00100000 01000000 10001111 1111 Comprehensive, to report all errors, you can put all error levels, a | B | C... The php.ini file can be set *///error_reporting (E_all);//settings Report all errors//error_reporting (0);//Do not report error//echo $a;//include (' cc.php '); /want to report all errors except NOTICE's error echo e_notice;//error_reporting (e_all ^ e_notice);//error_reporting (E_all); Error_reporting (E_ All & ~ e_notice); echo $a;
2, floating point number is not accurate
echo "<br/>"; if ((0.3-0.2) = = 0.1) {echo "equal";} Else{echo "Not Equal";} /*10 in 3.1, refers to the 3*10^0+1*10&-13:1.1, refers to the 1*3^0+1*3^-1;//corresponding to the decimal 1.3333 ... 10 binary 2 binary 0.5 0.10.8 Some decimals are limited in the 10 binary, and turn into 2 to infinite loops. Therefore, the loss of precision, resulting in floating-point arithmetic and mathematical book results inconsistent *///Bank General deposit Integer, accurate to the minute
3. Short-circuit characteristics of logic operations
echo "<br/>"; $h = false; $c = true;if ($h && $c) {//house is false, useful and calculated, the result is false, the program will not judge the value of $c echo ' false ';} Else{echo ' do not Marry ';} $b = 1;if ($h && ($b = 6)) {//$b = 6 shorted, no chance to execute}echo $b; if ($h | | ($b = 6)) {//$b = 6}echo $b; $b = 0;if ($c | | ($b = 6)) {//$b = 6}echo $b; echo "<br/>";//use short-circuit to write short judgment code if (!defined (' pi ')) {define (' pi ', 3.14);} Defined (' PI ') | | Define (' PI ', 3.14); echo "<br/>";//menstrual problem, operator precedence, first count | |, derive boolean, so the operation requires a parenthesis $ A = 3; $b = 5;if ($a = 5 | | $b = 7) {$a + +; $b + +;} echo $a. " ". $b; echo" <br/> ";
Rest ~ ~
This article from "A Big big waste fish" blog, declined reprint!
Abandoned fish--how long does PHP take to get from getting started to giving up? 14