Home > Backend Development > PHP Tutorial > PHP basics, variables, constants, structural statements

PHP basics, variables, constants, structural statements

WBOY
Release: 2016-07-29 09:11:13
Original
1102 people have browsed it

  1. Basic common sense:
    1. ?> can be omitted
    2. The string concatenator is.
    3. Note //
  2. Variables
    1. The first letter of the variable must be $, starting with a letter or underscore "_"
      It can only be composed of letters, numbers, and "_", and can also contain Chinese characters
      Case-sensitive
    2. The "var_dump" function can display the data type of our variables, and it has line breaks
    3. When we use the "echo" command to output the Boolean type, if it is "true", the output is "1", "false" will output nothing
    4. When a variable is contained in double quotes, the variable will be connected with the content in the double quotes;
      When a variable is enclosed in single quotes, the variable will be output as a string
    5. long string: delimiter <<< + any identifier + content + identifier
  3. constant
    1. define definition
    2. System constants
      (1)__FILE__: PHP program file name. It can help us get the physical location of the current file on the server.
      (2)__LINE__: The number of lines in the PHP program file. It can tell us which line the current code is on.
      (3) PHP_VERSION: The version number of the current parser. It can tell us the version number of the current PHP parser, and we can know in advance whether our PHP code can be parsed by the PHP parser.
      (4) PHP_OS: The name of the operating system that executes the current PHP version. It can tell us the name of the operating system used by the server, and we can optimize our code according to the operating system
    3. Constant value
      1. Use the constant name directly
      2. mixed constant(string constant_name);//Return a variety of information, failure Return error message
      3. bool defined(string constants_name); Determine whether the variable is defined
      4. Reference of variable &
      5. String concatenation operator
        1. .
        2. .=//Connection with assignment
  4. Structural statements
    (1) Only take the value, do not remove the subscript
    <br> <?php <br> foreach (array as value){ <br> //Tasks to be executed <br> } <br> ?> <br><br> (2) Remove the subscript and value at the same time <br><code><br> <?php <br> foreach (array as subscript => value){ <br> //Tasks to be executed <br> } <br> ?> <br>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced the basics of getting started with PHP, variables, constants, and structural statements, including all aspects. 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