"PHP, MySQL, JavaScript and css" reading----PHP Articles

Source: Internet
Author: User
Tags define function flock

1. Basic
    • Note://OR/* * *
    • $ flag Variable
    • End of statement plus semicolon
    • Array: $oxo = Array (' x ', ' ', ' o '), Array (' P ', ' X ', '), Array (', ' x ', ' P '));
    • Echo $oxo [other]
    • Constants: Can not be used before the $ symbol, can only be defined with the Define function
2. Object replication

Clone operator

$obj 2 = clone $obj 1;

3. Class
    • How to construct a class: __construct ()
    • Destruction method: __destruct ()
    • static method: Static Call User::static_function ()
4. Include_once and require_once.

Use Xxx_once as much as possible to prevent multiple definitions of constant or function errors with the same name

The problem with include_once is that PHP will only attempt to import the requested file, even if the file is not found and the program will continue to execute.

5. Terminology:
    • When creating a program that uses objects, you need to design a combination of data and code called classes. Any new object created by this class is called an instance (or event) of the class.
    • The data about the object is called a property, and the function used by the object is called a method.
    • When you define a class, you provide the name of the property and the code for the corresponding method:
    • With inheritance, the new class will have all the properties of the inheriting class.  The original class is called a superclass, and the new class is a subclass. Extends
    • When you derive a class and declare your own constructor method, PHP does not automatically call the parent class's constructor.  Be sure to know that all code is initialized, and subclasses always call the parent class's constructor. Parent::__construct ();
    • To prevent the subclass method from overriding the parent class method, you can use the keyword final
6. Print_r, which requires PHP to output variable information in the usual reading format (_R stands for "in regular reading format") 7. Array

One way to loop an array:

The foreach ($papers as $paper)//papers is an array, paper loops to get the elements in papers

foreach ($papers as $item = $description)

while (list ($item, $description) = each ($paper))

8. Using Array functions

Is_array ($fred): Checks if a variable is an array

Count ($fred): Count the number of elements in the top level of the array

Count ($fred, 1): Gets how many elements are in a multidimensional array. The second parameter is optional, 0 or 1, 0 limits only the number of top-level array elements, 1 mandatory, and the number of elements of the recursive statistic Subarray

Sort ($fred): Sorts directly on the provided source array. The sort succeeds returns true, and the failure returns false

Sort ($fred, sort_numeric); : Force sorting by value

Sort ($fred, sort_string); : Force sorting by string

Rsort () Sort by reverse order

Shuffle ($fred) sorted by random order

Explode () allows you to accept a string of independent items containing several single letters (or strings) and put them in an array. It is common to break a sentence into an array that contains all the words. The first parameter represents a delimiter

Extract ($_get) Saves the value passed to the variable.

Compact () creates an array with variables and their values

9. Output

printf controls the output format of text by formatting characters

sprintf passing results to another variable instead of a browser

10. Time

Date ($format, $timestamp)

Mktime (hours, minutes, seconds, month scores, days, years)

Time ()

11. File Processing

File_exists detecting whether a file exists

fopen

Fgets () read a file to get a whole line of data

Fread () reads some data from multiple lines of data or multiple rows

Copy ("Test1.txt", "test2.txt") copies the file

Rename () move file or rename

Unlink Deleting files

Flock ($FH, LOCK_EX) is a file yoke for multi-user access

Flock ($FH, Lock_un) release exclusive lock

File_get_contents read entire file (even request HTML file via URL to display page to screen)

12. System Calls

EXEC ()

"PHP, MySQL, JavaScript and css" reading----PHP Articles

Related Article

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.