PHP interview questions, php questions
Tip: Set the PHP file character encoding header ("content-type: text/html; charset = UTF-8") before the test code ");
1.
1.1 Use PHP to get the current time and print it. Format: 22:19:30
2.
2.1 convert string to array
$ Str = "www.baidu.com ";
$ Arr_str =Explode('.', $ Str );
Print_r ($ arr_str); // Array ([0] => www [1] => baidu [2] => com)
Echo '<br/> ';
Print_r (Str_split($ Str); // Array ([0] => w [1] => w [2] => w [3] =>. [4] => B [5] => a [6] => I [7] => d [8] => u [9] =>. [10] => c [11] => o [12] => m)
2.2 convert an array to a string
$ Arr = array ('aaa', 'bbb ', 'ccc ');
Print_r (Implode(',', $ Arr); // aaa, bbb, ccc
Echo '<br/> ';
Print_r (Join('-', $ Arr); // aaa-bbb-ccc
2.3 string Truncation
$ Str = "a, B, B, d. e, f. g/h? ";
Print_r (Substr($ Str,); // a, B single-byte Truncation
Echo '<br/> ';
$ Mb_str = "Hello Beijing, hahaha, hahaha ";
Print_r (Mb_substr($ Mb_str,); // multi-byte Truncation
Echo '<br/> ';
Print_r (Mb_strcut($ Mb_str,); // multi-byte Truncation
2.4 string replacement
$ Date = '2014/1/123 ';
EchoPreg_replace('/(\ D +) \/(\ d +)/', '$3/$1/$ 2', $ date ); // 2003/08/26