PHP Learning Essays

Source: Internet
Author: User
Tags epoch time md5 encryption

---restore content starts---

Round formatted numeric values (carry rules adhere to "quad six into five pairs", that is, the previous one is odd, then into one, the former is an even number rounded, therefore, rount (1.5) =2,round (2.5) =2,round (0.15) =0.2;round (0.005) =0)

(Ceil floor ABS)

Number_format ();

More complex printf () and sprintf () functions to format numeric values (not recommended)

To create a random number:

Rand ();

Mt_rand () (password)

How to link

.

NL2BR (keep the original format)

Security issues

Htmlspecialchars () converts a specific HTML tag to an entity version

Htmlentities () converts all HTML tags to the bit entity version

Strip_tags () Remove all HTML and PHP tags

The Html_entity_decode () function converts an HTML entity into the appropriate HTML code

Cryptographic functions

Crypt ()

Mcrypt_encrypt () Mcrypt_decrypt () But usage and syntax are more complex (MCrypt extensions must be installed with PHP modules)

Find string

Strtok

PHP Index starting from 0

Extracts a string based on an index substr strlen (including spaces and punctuation) the Str_word_count () function Gets the number of words in the string

strcmp strnatcmp () strcasecmp () strnatcasecmp (); Strstr

Replace local string

Str_ireplace (); (case insensitive)

Str_replace ();(case sensitive)

Trim (); (removes all whitespace from the beginning and end of the string)

Validation functions

Empty ();

Isset () returns True when a variable has a value (including 0.false or an empty string)

Is_numeric () function

$_server $_get $_post $_cookie $_session $_env Hyper global variable

Array

Index starting from 0

Range

unset Deleting an array

Array () reset (reset) arrays

sizeof is an alias of Count that can return the number of array elements

Note conflicts with symbols in the array when print

Foreach

You can create multidimensional arrays

Array sorting

Sort

Conversion of strings and arrays

Implode array into a string

Explode string Conversion bit array

The list () function is used to assign the value of an array element to a separate variable

Constants are usually enclosed in quotation marks, but numbers are not used to print the constants inside the quotation marks

#defined

January 1, 1970 Midnight VII calculated seconds This moment is called the Epoch Time () function to return the timestamp of the current moment

Date_default_timezone_set (' america/new_york ');

<input type= "hidden" name= "submitted" value= "true"/>

Output buffer, can resolve HTTP header has been sent error--〉ob_start ();

Ob_end_flush () sends the accumulated buffers to the Web browser

The Ob_end_clean () function removes buffered data without transmitting

A cookie is a way for a server to save user information on a user's computer, while the server can remember the user during the access process or multiple accesses. Cookeie is like a name tag: The user computer informs the server user name and gives a name tag. The server can then know who the user is by name tag.

Setcookie (Name,value);

A session is a solution that tracks the data that a user accesses in a series of pages, the main difference being that Cookeie saves the data to the client, session

Save the data on the server side,

Session_Start () created. Access and delete session

$_session=array (); Session_destroy ();

PHP function names are case insensitive

File_exists (") can test if the file exists

Touch creates a blank file

The concept of the Web root is the underlying URL

File_put_contents ($file, $data, file_append);

Find all content in a directory Scandir ($DIR);

FileSize () Check the size of the file

The FILETIME () function is used to retrieve the modified time of a file

mkdir Creating a Directory

MD5 encryption

View_quote.php ();

RmDir () function to delete an existing directory

Fgets () function

The feof () function ensures that the end is not reached

Fgetcsv ($fp, Length,delimiter);

Ini_set (' auto_detect_line_endings ', 1);

$dbc =mysql_connect (Hostname,username,password);

Mysql_close ($DBC);

File_get_contents (); The entire string to handle

File (); processing each row has some data

$_files

Mysql

Change Password Note the command should be added after

Mysql_error () function, which can return MySQL server to return text information about the error

The @ in the @function_name does not prevent the error from occurring, just prevents the error message from appearing immediately

/* * MYSQLI * Database address, login account, password, database name *    /$mysqli = new mysqli ("localhost", "root", "" "," student ");    $sql = "SELECT * from Tb_user";    $result = $mysqli->query ($sql);    $row = $result->fetch_assoc (); Get a row from the result set as an associative array    echo $row ["Password"];    /* Free Result set *    /$result->free ();    /* Close connection *    /$mysqli->close ();
Reprint: http://www.runoob.com/php/func-mysqli-error.html (mysqli month MySQL difference and usage)

---restore content ends---

PHP Learning Essays

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.