PHP job search book-Basic notes for PHP language 2

Source: Internet
Author: User

Use PHP to obtain the previous day in the format of 12:00:00

Use the date () function to obtain the current time of the system. To obtain the time of the previous day, use the strtotime () function to obtain the timestamp of the previous day, and then use date () the Function Format and outputs The timestamp of the previous day:

1 <? PHP 2 Echo date ('Y-m-d h: I: s', strtotime ('-1 Day'); 3 4 5 // or: 6 7 $ YEST = Time ()-(24*60*60); 8 Echo date ('Y-m-d h: I: s', $ YEST ); 9 10?>

 

String flip function:

Strrev ();

 

How to extract Chinese strings without garbled characters:

The mb_substr () function can directly intercept Chinese strings without garbled characters.

This function is used to intercept Chinese strings. It can avoid garbled characters when intercepting Chinese strings, intercept the strings, and intercept Chinese strings:

  string mb_substr(string str,int start [,int length [,string encoding]]);

 

Write a regular expression to match the email address and URL address:

Email:/\ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W + )*/

URL:/^ http: \/[\ W] + \. [\ W] + [\ s] */

 

Replace character 09 with a decimal number:

  echo octdec('09');

 

Replace 1234567890 with 1,234,567,890:

echo number_format('1234567890');

 

 

Write a function to retrieve the file extension from a standard URL as efficiently as possible:

<?php    $path="http://sina.com.cn/abc/de/fg.php?id=1";    echo substr(basename($path),0,strripos(basename($path),"?"));?>

 

Add John to the users array:

$ Users [] = "John ";

Array_add ($ users, "John ");

Array_push ($ users, "John ");

 

Differences between sort (), asort (), and ksort:

The sort () function is used to sort the array of the numeric index. The asort () function is used to sort the arrays that are very important to the unit order. ksort () the function is used to sort common joined arrays.

 

Implode () function:

Combines array elements into a string.

implode(separator,array)
Parameters Description
Separator Optional. Specifies the content to be placed between array elements. The default value is "" (Null String ).
Array Required. Array to be combined as a string.

 

Calculate the file size:

The file size is generally used to read binary image files. The format is as follows:

Int filesize (string filename );

Returns the number of bytes of the file size. If an error occurs, false is returned.

  

Use the disk_free_space () function to calculate disk space:

Float disk_free_space (string directory );

 

Total disk capacity:

Float disk_total_space (string directory );

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.