Php interview questions-BASIC program Questions
Print the time format of the previous day in PHP: 22:21:21
date('Y-m-d H:i:s', strtotime('-1 day'));
How to implement string flip?
Method 1:
Method 2:
Write a function to traverse all files and subfolders in a folder.
Please write a function to verify that the email format is correct
There is a webpage address, such as the PHP development resources home page: http://www.phpres.com/index.html. how can I find my website content?
Method 1 (for php5 and later versions ):
Method 2:
How to obtain the path of the script to be executed, including the obtained parameters.
Note: for example, there is a script www.domain.com, and the parameters passed to it include parameter 1, parameter 2, parameter 3 .... The method for passing parameters may be GET or POST,
So now please write like http://www.domain.com/script.php? Result of parameter 1 = value 1 & parameter 2 = value 2...
No answer
Write a sorting algorithm, which can be bubble sorting or fast sorting. assume that the object to be sorted is a one-dimensional array.
(Note: you cannot use existing functions of the system. remember the basic knowledge you have learned before)
Quick_sort ($ left_arr); $ right_arr = $ this-> quick_sort ($ right_arr); return array_merge ($ left_arr, array ($ key), $ right_arr );} /*** Hill sorting */public function shell_sort ($ datas) {// group for ($ increment = count ($ datas)/2; $ increment> 0; $ increment = $ increment/2) {// sort each group for ($ I = $ increment; $ I <count ($ datas); $ I ++) {$ temp = $ datas [$ I]; $ j = 0; for ($ j = $ I; $ j >=$ increment ; $ J = $ j-$ increment) {if ($ temp <$ datas [$ j-$ increment]) {$ datas [$ j] = $ datas [$ j-$ increment];} else {break ;}$ datas [$ j] = $ temp ;}} return $ datas ;}}?>
There is a table menu (mainmenu, submenu, url). please use recursion to write a tree menu and list all menus.
No answer
You can write a program to find the maximum number.
No answer
There is an array $ a = array (, 2); sort it again and list it in ascending order.
No answer
Write two regular expressions that match the email address and URL. Similar to the following:
Email Address: user_name.first@example.com.cn
URL: http://www.example.cpm.cn/user_profile.php? Uid = 1, 100
(Note: The standard regular expression is the regular expression that can be parsed by the regular expression of the preg _ * class in php)
Email:/\ w + ([-+.] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w + )*/;
URL:/^ http: \/[\ w] + \. [\ w] + [\ S] */
Write a piece of code in php. If no 3rd variables are used, the values of $ a and $ B are exchanged, and the initial values of $ a and $ B are set.
Write a function to retrieve the file extension from a standard url as efficiently as possible.
Example: http://www.sina.com.cn/abc/de/fg.php? Id = 1 need to retrieve php or. php
Answer 1:
Answer 2:
Write a function to calculate the relative path of the two files.
For example, $ a = '/a/B/c/d/e. php ';
$ B = '/a/B/12/34/c. php ';
The relative path of $ B relative to $ a should be ../c/d.
0 ) { $returnPath = array_merge( $returnPath, array_fill( 1, $len - $n, '..' ) ); } $returnPath = array_merge( $returnPath, array_slice( $arrA, $n ) ); return implode( '/', $returnPath ); } echo getRelativePath( $a, $b );?>