PHP Preliminary involved

Source: Internet
Author: User

PHP Overview

N PHP (foreign name: Php:hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a free open source server-side scripting program. Conducive to learning, widely used, mainly for the field of web development. Can run under UNIX, LINUX, Windows.

N as a background language, standard variables, data types, operations, selection structures, looping structures, functions, arrays, are the same as most programming languages. The only difference, basically, is in some syntax.

Server Installation + environment configuration

Wampserver Software

Wampserver is a French-developed Apache web server, PHP interpreter, and MySQL database Integration Package.

delimited identifier extension . php <?php?> or <?phps

identifiers /keywords

N identifiers: identifier is the name of the variable , with respect to identifiers,PHP defines a few simple rules:

identifiers can be of any length and can be any letter, number, underline .

identifiers cannot start with a number .

in PHP, identifiers are case-sensitive.

N Keyword : keywords have a special meaning in PHP. Some of them are like functions, some like constants ... But they are not, they are only part of the language structure. You cannot use any of them as constants, method names, or class names. However, they can be used as variable names, but this leads to confusion.

The data type --php supports 8 basic data types.

Four types of scalar:

Boolean (Boolean) Integer (integer)

Float (floating-point, also called Double) string (string)

Two kinds of composite types:

Array (Array) object (object)

Finally, there are two special types:

Resource (Resource): resources are created and used by specialized functions, such as open files, data connections, and graphical canvases. We can manipulate resources (create, use, and release).

Null (NULL)

PHP is a very weak type of language . In most programming languages, a variable can hold only one type of data, and that type must be declared before the variable is used. In PHP, the variable's type is determined by the value assigned to the variable.

acquisition and setting of data types:GetType () Settype ()  

PHP output: Echo, print, Print_r, Var_dump

N Echo, print itself is a function , but the output function here can omit parentheses, with a space plus the string or variable that you want to display. The difference is that ECHO has no return value, and print has a return value of type int of 1.

N Print_r's function is to print a variable of easy-to-understand information, and the difference between echo and print, such as the output of an array, echo and print output is an array, and the Print_r output in addition to the array, but also the members of the arrays will be printed out.

N The difference between Var_dump and Print_r, var_dump lists the details of the variables, while Print_r lists some basic information that is easy to understand.

Select structure, loop structure

N if...else ...

N Switch

N For Loop

N while/do...while ...

function

N Declaration and invocation of custom functions

N Arguments for a function (parameters specify default values) and return values

N function calls that return multiple values

N Scope of the function

N A function that contains reference arguments: Reference passing can modify parameters within a function to be valid outside the scope of the function. &

Concepts of objects and classes

N Objects ( object)

An object is a thing, an entity, a noun that can get something that can be imagined to have its own identity for any

Things. An object is an instantiation of a class.

N Classes ( Class)

A class is a definition of an object. It contains information about how the object acts, including its name, method, properties

and events. In fact, it is not an object in itself, because it does not exist in memory. When the code that references the class is run, the class's

A new instance, the object, is created in memory. Although there is only one class, it can be created in memory from this class

Multiple objects of the same type.

N class creation and declaration of objects

N - pointer to struct member operators

N Each class's definition begins with the keyword class followed by the class name followed by a pair of curly braces containing the definition of the class's properties and methods.

N To create an instance of a class, you must use the new keyword


PHP Preliminary involved

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.