Php basics 2: common functions

Source: Internet
Author: User
Document directory
  • Syntax
  • Syntax

Define ()A function defines a constant.

Constants are similar to variables, except that:

    define(name,value,case_insensitive)
    Parameters Description
    Name Required. Specifies the name of a constant.
    Value Required. Specifies the value of a constant.
    Case_insensitive

    Required. Specifies whether the constant name is case sensitive.

    If it is set to true, it is not case sensitive. The default value is false (case sensitive ).

     

    Isset-Check whether the variables are set.

    Bool Isset(Mixed $ Var[, Mixed $ Var[, $...])

    IfVarIf yes, returnTRUEOtherwise, returnFALSE. If you have used unset ()
    After a variable is released, it will no longer beIsset (). If you useIsset ()TestNULLWill returnFALSE. Note thatNULL
    Byte ("\ 0") Is not equivalent to PHP'sNULLConstant.

     

    Unpack ()
    The function unpacks data from a binary string.

    Syntax
    unpack(format,data)
    Parameters Description
    Format Required. Specifies the format used to unpack data.
    Data Optional. Specifies the binary data to be unwrapped.

    Fread

    Fread-read files (which can be safely used for binary files)

    StringFread(Int$ Handle, Int$ Length)

    Fread ()Slave file pointerHandleRead MostLengthBytes. This function can be used upLengthNumber of bytes, or when the EOF is reached, or (for network streams) when a package is available, or (after opening the user space Stream) when 8192 bytes have been read, the system stops reading files.

    Returns the read string. If an error occursFALSE.

     

    Str_repeat ()

    The number of times the string is repeated.

    Syntax
    str_repeat(string,repeat)
    Parameters Description
    String Required. Specifies the string to be repeated.
    Repeat Required. Specifies the number of times the string will be repeated. Must be greater than or equal to 0.

    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.