PHP Small Note

Source: Internet
Author: User

PHP Get Date:

Date_default_timezone_set (' PRC '); Default time zone

"Today:", Date ("Y-m-d", Time ()), "<br>";
"Today:", Date ("Y-m-d", Strtotime ("June")), "<br>";
"Yesterday:", Date ("Y-m-d", Strtotime ("1 day"), "<br>";
"Tomorrow:", Date ("Y-m-d", Strtotime ("+1 Day"), "<br>";
"One week later:", Date ("Y-m-d", Strtotime ("+1 Week"), "<br>";
"2 days a week four hours two seconds later:", Date ("Y-m-d g:h:s", Strtotime ("+1 Week 2 Day 4 hours 2 Seconds"), "<br>";
"Next week Four:", Date ("Y-m-d", Strtotime ("next Thursday")), "<br>";
"Last Monday:". Date ("y-m-d", "Strtotime"). " <br> ";
"One months ago:". Date ("Y-m-d", Strtotime ("last month")). " <br> ";
"One months later:". Date ("Y-m-d", Strtotime ("+1 Month")). " <br> ";
"Ten years later:". Date ("Y-m-d", Strtotime ("+10 Year")). " <br> ";

Array Length: count ();

Random number: rand ($min, $max);

Open the file with fopen, with the feof loop to read the file, each time with the Fgets method will only read a row, only each call fgets method will let the reading data cursor down one line, so if you do not need to read all the words can be read again, Use continue to jump out of the loop when not needed

When you open a file with fopen and write to the content with Fwrite, a new file is created automatically if the file does not exist

In CL:

$this->db->where ("$search between Start and end", null, FALSE);

The first parameter is the SQL statement, the second argument is empty, and the third parameter indicates whether $search is added to provide protection, and if quotation marks are added, this $search is the field name or table name, etc.

The Ip2long () method converts the IP into a digital

Long2ip () Convert numbers to IP

PHP regular match:

Match a number in a $str

$str = "memtotal:502216 KB";
Preg_match (' # (\d+) # ', $str, $matches);

echo $matches [0];//output 502216

Regular validation, which returns TRUE or False

Mb_ereg ("^[\w\-\.") {1,32}$ ", $str)

The above content is I in the actual study development summary and record, for reference!

PHP Small Note

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.