Common php library functions

Source: Internet
Author: User
: This article mainly introduces common php library functions. For more information about PHP tutorials, see. 1) time and date

It mainly involves time () and date ();

 '; // Echo date_default_timezone_get (); // Set the time zone date_default_timezone_set ('Asia/Shanghai'); // output data echo date ('Y-m-d H: i: s'); echo'
'; // Convert the timestamp to the date echo date ('Y-m-d H: I: S', '123 ');
2) json format data operations:

It mainly involves json_encode () and json_decode ();

 'Lily', 'age' => 23); print_r ($ arr); echo'
'; Echo json_encode ($ arr); // Convert the key-value pair object to data in json format $ obj = array ('H' => 'hello ', 'W' => 'world', array (3, 5, 7); echo'
'; Print_r ($ obj); echo'
'; Echo json_encode ($ obj); // Convert data in json format to a key-value pair object $ objJson =' {"h": "hello", "w ": "world", "0": [5, 7, 8]} '; $ myObj = json_decode ($ objJson); echo'
'; Print_r ($ myObj); echo'
'; Echo $ myObj-> w;
3) file operations:

Fopen (), fwrite (), fclose (), fgets (), file_get_contents (), and so on;

 
/*** Read data */$ rf = @ fopen ('data', 'r'); // fgets () read-only row while (! Feof ($ rf) {$ c echo $ content;} fclose ($ rf );
// Php provides a method to directly obtain all the content of the file echo file_get_contents ('data ');
4) generate images. for more methods, click the php image method.

  


5) watermark the image

   

For more details, refer to the php Chinese manual.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above describes common php library functions, including some content, and hope to help those who are interested in PHP tutorials.

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.