: 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.