Basic Knowledge of PHP overview

Source: Internet
Author: User
Tags define constant continue goto integer variables php basics variable
PHP Basics   The number of the plastic in PHP is signed, can not represent unsigned integers, when the number of plastic is out of range, automatically from the number of changes to float, you can use the Php_int_size constant to see the php integer type of bytes, typically 4 bytes, So you can estimate the range of the number of plastic, the highest digit sign bit. You can also use the Php_int_max constant to view the maximum value of an int.   Small Knowledge points:   1.   When the variable is 0.0 or "0" in the Boolean variable is false;   2.   A string variable with double quotes where the variable and escape characters can be defined as normal output, and the output of the content in single quotes, it will output its content, that is, the escape character or variable does not work, but only the original output literal, this can write the code to see the difference. The definition of a PHP variable is a bit like JS, because you don't need to specify any type of it at all, depending on the type you're actually using.   3.   PHP arithmetic operator:   Note point: Division "/" The result can be an integer or float. Instead of just integers, for example, 5/2 results are 2.5, and in c the result is 2. When the result is not endless, the results show 14 digits.   Operators have a total of  +  ,- ,  *  ,  / ,  %   five operators.   The symbol for connecting two strings is not the + number in Java, but the. The dot number will automatically treat the front and back variables as strings.   the difference between "= =" and "= =": the   "= =" symbol indicates that only the left and right values are equal to true.   "= =" symbol indicates that both the left and right values are equal, and the variable type should be equal to return true.   The following example:   $a = 2;   $b = 2.0; The values of the $a and $b variables are equal in the   example, but the types are not equal! all with = = is true, use = = is false.   $a!== $b indicates true if A and B values are not equal or if the type is unequal.   $a!= $b that the result is true only if the values of a and B are not equal. The   $a <> $b represents the same meaning as $a!= $b.   echo   $a = = $b output is not tRue or False. Instead of 0 and 1, 1 represents true,0 for false.   There are >=, <= symbols that are greater than or equal to, less than or equal to each other.   Logic judgment has a special, when the previous judgment is true, the expression after the "" symbol will not execute, so be careful! Empathy && symbols are similar. This phenomenon is called short circuit. Short circuit with and short circuit or is one of the representatives. Symbols can be replaced with or. Empathy && symbols can be replaced with and. But the English or and and is somewhat different: the OR operator is lower than = low. For example   $a = false true;   &NBSP;//A returns true;   $a = false or true; = "($a = false) or true;   Var-dump ($a, $b); The same is the case with the   ampersand.   type operator: instanceof, which is used to determine whether the data is an instance of a class, similar to Java, and returns True or false.   + + and-operators are only for variables and cannot be used on constants!   SWITCH Statements in PHP can be Boolean types in parentheses! And the string "0" is treated as false. The default statement can be placed anywhere without affecting the order in which other case statements are executed! Even the first sentence in the switch statement. But be careful to remember to write the break statement.   form submission question:   In Firefox, the form submission method is POST, the corresponding get field is worth $_post, not $_request, and in IE or Firefox, whether it is POST or get can be used $_ Request to get the content. The $_request parameter corresponds to the Name property value of the form's corresponding INPUT element. The break statements in       PHP are different:   must first understand what is a loop? A loop is a part of a for, a while keyword called a loop, which is different from the curly braces of an if statement, which is generally placed in an if statement and is generally used to skip the current loop of the For loop or the while loop for the continue. Do not assume that in the for loop the curly braces represent a loop, and the curly braces under the If statement are not loops. The   break statement can be followed by a number that jumps out of the first layer of the loop, in the break languageThe curly brace area of the sentence is the first layer loop. In turn to the outside accumulator, but not from the outside to the increment. But notice that the numbers are too big to go beyond the outermost loop! For example, a total of only 3 layers of circulation, you have to jump 4 layers, this will be wrong! Break default jump Loop layer number is 1. The   Continue statement is used to end this loop, skipping the rest of the code in the loop to start a new loop. The   goto statement is only valid   goto for php5.3 or above versions: A break statement that is used to jump out of loops instead of multiple loops. Make the code more concise!   The difference between variables and constants in PHP:   1.   constants are not preceded by a dollar sign.   2.   constants are defined by the Define () function or const and cannot act as the left value of an assignment statement.   3.   constants can be used and accessed anywhere, regardless of the scope of the variable.   4.   Constants cannot be redefined or redefined once they are defined.   5. The value of the   constant is the scalar "base data type float, int, string, boolean".   defines two forms of a constant:   define ("Int_max", 255) or const int_max=255; You cannot add a dollar sign before a constant, nor can you reassign a value.

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.