PHP face question set-basic procedural questions

Source: Internet
Author: User
Tags preg
Basic Procedural Questions


The time format for printing out the previous day in PHP is 2006-5-10 22:21:21
Date (' y-m-d h:i:s ', Strtotime ('-1 day '));

How do I implement string flipping?
Method One:
 
  
Method Two:
 
  

Write a function that can traverse all the files and subfolders under a folder.
 
  

Please write a function to verify that the e-mail format is correct
 
  

There is a web address, such as the PHP Development Resources Web page: http://www.phpres.com/index.html, how to get its content?
Method one (for PHP5 and later versions):
 
  
Method Two:
 
  

How to get the current execution script path, including the obtained parameters.
Description: For example, there is a script www.domain.com, the parameters passed to him are parameter 1, parameter 2, Parameter 3 ... the method of passing a parameter is possible that get is a post,
So now please write something like http://www.domain.com/script.php? Parameter 1= value 1& parameter 2= value 2 ..... The results
No answer at this stage

Write a sort algorithm that can be a bubble sort or a quick sort, assuming that the object being sorted is a one-dimensional array.
(Hint: You cannot use the system already has functions, please also carefully recall the basic knowledge previously learned)
 Quick_sort ($left _arr);        $right _arr = $this->quick_sort ($right _arr);    Return Array_merge ($left _arr, Array ($key), $right _arr); }/** * Hill sort */Public function Shell_sort ($datas) {//Group for ($increment = count ($data s)/2; $increment > 0;                $increment = $increment/2) {//Sort within 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 the recursive method to write out a tree menu, all the menu listed.
No answer at this stage

Give you three number, write the program to find its maximum value.
No answer at this stage

There is an array $a =array (4,3,8,9,2); Please reorder them, listed in order from small to large.
No answer at this stage

Write out two regular expressions that match the mailbox address and URL. Similar to the following:
Email Address: user_name.first@example.com.cn
URL Address: http://www.example.cpm.cn/user_profile.php?uid=100
(Hint: Use standard regular expressions, that is, the regular handler function of the Preg_* class in PHP can parse the regular)
E-Mail:/\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) */;
Url:/^http:\/\/[\w]+\. [\w]+[\s]*/

Write a piece of code in PHP, the implementation does not use the 3rd variable, Exchange $ A, $b value, $a, $b the initial value of their own.
 
  

Write a function that removes the file extension from a standard URL as efficiently as possible
For example: http://www.sina.com.cn/abc/de/fg.php?id=1 need to remove PHP or. php
Answer 1:
 
    
Answer 2:
 
    

Write a function that calculates the relative path of two files
such as $a = '/a/b/c/d/e.php ';
$b = '/a/b/12/34/c.php ';
Calculate $b relative path 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);   }   
  • Related Article

    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.