Php beginners and beginners

Source: Internet
Author: User

Php beginners and beginners
Start and end tags

  1. There are two common types:<?php ?>,<script language="php"></script>
  2. Short mark:<? ?>To open the short_open_tag command of the php. ini file
  3. Asp style tag:<% %>To open the asp_tags command of the php. ini file
Php Data Types (9 types)
  1. Four scalar types
  • Boolean
  • Integer
  • Float
  • String
  1. Three composite types
  • Array
  • Object
  • Callable)
  1. Two special types
  • Resource)
  • NULL (no type)
  1. Pseudo type
  • Mixed (mixed type)
  • Number)
  • Callback (callback type, also called callable)
  • Array | object
  • Void
  1. Pseudo Variable $...
  2. Type detection function (is_type), eg:is_string($str)
Super global variable
  • $ GLOBALS
  • $ _ SERVER: stores information about the header, path, and script location.
  • $ _ REQUEST: Collect html form submitted data
  • $ _ POST
  • $ _ GET
  • $ _ FILES
  • $ _ ENV
  • $ _ COOKIE
  • $ _ SESSION
Access global variables in the function body
  • Global $ variable_name
  • $ GLOBALS [variable_name]
Set Constants

define(const_name, const_value, boolean)

  • Const_name: constant name
  • Const_value: Constant Value
  • Boolean: the constant name is case sensitive. The default value is false. true is not sensitive.
Create an array
  • array()
  • Get array Lengthcount($arr)
  • Array sorting: ascendingsort(), Descending orderrsort()
  • Sort array keys in ascending orderksort(), Descending orderkrsort()
  • Sort array values in ascending orderasort(), Descending orderarsort()
Foreach loop (used only for arrays)
  • foreach($array as $value) {}
  • foreach($array as $key => $value) {}
Magic variable
  • __LINE__: Current row number
  • __FILE__: Complete file path and file name
  • __DIR__: Directory of the file
  • __FUNCTION__: Function name
  • __METHOD__: Class Method Name
  • __NAMESPACE__: Name of the current namespace
Object-oriented
  • Class Name is added after the class keyword is used
  • Variables and methods can be defined in a pair of braces ({}) after the class name
  • Class variables are declared using var, and variables can also be initialized.
  • Function definitions are similar to php functions, but can only be accessed through the class and its instantiated objects.

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.