[Fengma family _ php] basic php knowledge, _ basic php knowledge

Source: Internet
Author: User
Tags constant definition php basics

[Fengma family _ php] basic php knowledge, _ basic php knowledge
Review

What is the development history of php and php?

  • Configure php in apache
  • Configure mysql in php
  • How apache works
  • How the web works (similar to 4)
  • Domain name-based VM configuration: httpd. conf loads httpd_vhost.conf and httpd_vhost.conf to configure the VM.
  • Bytes ---------------------------------------------------------------------------------------

    PHP work

    Php is a scripting language embedded in html code.

    If the file does not use. if php ends, the apache file will not be handed over to php for processing, so the php code will be handed over to the browser intact, and the browser cannot parse the php code, so it will not output the final php code execution results

    1. Embed php code in an html file

      

    2. Embed php code in html in the php File

        

    Note: apache will submit all files ending with. php to the php engine for processing. The php engine only processes php code and does not process other non-php code.

    Bytes ---------------------------------------------------------------------------------------------------------------

    Php independent files

    No other code (html) is purely php code. (If you do not want to work with apache, you only need to use the php.exe file to run the PHP file.

      

    Bytes ---------------------------------------------------------------------------------------------------------------

    Php basics php labels

    1. Common labels

    <? Php

    // Php code

    ?>

    Is the most common label Method

    2. php script tag

    <Script language = "php">

    // Php code

    </Script>

          

    Note: script labels are rarely used because they are easy to be confused with javascript labels.

    3. Short tag

    PHP does not support short labels by default. You need to set D: \ service \ php. ini in the configuration file.

    <?

    // Php code

    ?>

    Effect

         

    Note: by default, php does not support short tag syntax and must be enabled in the configuration file.

     

    PHP comments

    There are two types of php comments: Single-choice comments and block comments (multiple lines)

  • :#
  • Block comment/* Comment content */
  • PHP Variables
  • Variable naming rules
  • Variables in php are usually assigned values during definition.
  • Syntax Error
  • Weak Language
  • I. Use Variables

    Use the variable directly. The precondition is that the current variable has been assigned a value (defined)

    Output: echo $ variable name;

    Judgment: if ($ variable name = 'value ')

          

    2. Modify Variables

    Assign a new value to the original variable.

    // Define variables

    $ Age = 20

    // Modify the variable

    $ Age = 34

        

    Echo $ age // 34

     

    3. delete variables

    Release the value pointed to by the variable (release the variable itself)

    Unset (variable name)

     

    // Output released Variables

    $ Age = 10;

    Unset ($ age)

    Echo $ age // error undefined

        

    Php Constants

    Once defined, it cannot be modified. The 'quantity' that can only be used is called a constant.

        

    I. Syntax

    Define ('constant name', constant value );

    Ii. Common sense syntax 3: Use of constants

          

    Iv. Constant naming rule 5: Memory principle diagram of variables and constants

      

    6. How does the memory handle php script execution? 7. Note:
  • End symbol of the concluding sentence: English symbol;
  • Constant definition is loose than variable definition.
  • Suggestions on naming variables and constants
  • -----------------------------------------

    Data Type

    The data type is for various (variable) values, not for the variable itself

  • Floating Point Type
  • Timestamp
  • String
  • Double quotation marks
  • Concatenate two strings without spaces
  • Delimiters
    Use a special symbol <to add a pair of start and end tags to include strings.
  • Definition of delimiters
  • Buddha: single quotes are more efficient than double quotes, because single quotes do not need to parse the variables and other content, as long as they are directly output.
  • Boolean
  • Composite data type
  • Special Data Types
  • Resource: all external data operations are called resource data.
  • Hexadecimal conversion

    Conversion between binary, octal, decimal, and hexadecimal

    System predefined Variables

    The variables defined by the system are called pre-defined variables. There are nine pre-defined variables.

    System predefined constantVariable

    Get the value of a variable and use the value as a variable name to get the value of another variable.

    That is, the value of the variable, as a variable of another value.

    Pass Value

    Value assignment between variables


  • Unset Principle
  • Swap variable value (both variables are integers)
  •           

     

     

     

     

     

     

         

    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.