PHP Basics 1

Source: Internet
Author: User

PHP: Equivalent to a wall between the client and MySQL Apache (Apache): is the Web server software localhost: equivalent to a domain nameFirst, Wampserver
    • HTTP.CONF: Used to configure Apache
    • PHP.ini: Used to configure the PHP language
    • My.ini: Used to configure MySQL
ii. Basic PHP statements
    • Format: <?php?>
      • Output: Echo
        • Output system time: <?php echo Date ("y-m-d h:i:s");? >
    • Variable declaration: $a = 3;
    • Line break: echo "
Third, PHP "+" and JavaScript "+" Difference
    • JS "+" number contains the addition and character stitching two meanings
    • PHP's "+" only adds this meaning
iv. PHP Character stitching symbol-"."Example: $str 1.$str 2
    • '. = ': equivalent to + =,-=, *=,/= and other symbolic usages
Five, PHP "," ", {} three differences
    • Single quote ': The contents of a single quotation mark are simply strings and have no meaning
    • Double quotation mark "": Content in the meaning, variables, arrays, etc. have their own meaning
    • Curly braces {}: General variables in curly braces
    • Note:
      • echo "I am the number". $str 1. " 2 ";
      • echo "I am the number {$str 1}2";
      • The same output effect
Six, Value assignment
    • $str 2= $str 1;
    • Assign the value of $STR1 directly to $STR2
Vii. Reference Assignment
    • $str 2 = $str 1
    • $STR2 points to the value of $STR1, $str 1 changes, $STR 2 will change as well.
Variables of variables
    • $val _1= ' Hello ';
    • $ $val _1= ' world '; Turn $val_1 into a variable
    • Echo $hello; --Output world
    • echo ${$val _1}; --Output world
Nine, connect, create an HTML and a PHP file
  • Form.html content:
    • <Body>    <formAction= "get.php"Method= "Get">        <inputtype= "text"name= "User">        <inputtype= "Pass"name= "Pass">        <inputtype= "Submit">    </form></Body>
  • get.php content:
      • <? php     var_dump ($_get);    echo $_get[' user ';    foreach ($_get as $key = $value) {        echo $value.  ?>
10. Get and Post
    • Get: Is IP-insecure and therefore unsafe
      • PHP section with $_get to receive
    • Post: Is protocol-safe, but relatively slow
      • PHP section with $_post to receive
11. Array:Request an array: $arr =array (All-in-one);12. For Loop
    • Traditional for loop: for ($i =0; $i <100; i++) {...}
    • A For loop in JSON form:
      • foreach ($obj as $key = = $value) {...}
        • Work with each content
      • foreach ($obj as $value) {...}
13, COUNT ($arr): array length14. Server Variable $_server
    • This global variable contains information about the server and client configuration and the current request environment
15. Define Constants (invariant)
    • Define ("PI", 3.1415926); Echo pi;     --Output 3.1415926
16. System version--php_os
    • PHP version: Php_version
17. Magic Constant
    • File Current line number: __line__
    • Function Name: __function__
18. Delimiter
    •     $str 2=<<<end    ...    --> Here The content is meaningful, meaningless characters are used as the normal character end;  It must be on the top side here.
19, GetType ($a)Determine the data type of a20, Is_int ($a)
    • Determines whether a is an integral type, or returns a Boolean value of true, otherwise false. The rest .

PHP Basics 1

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.