PHP Technician-Oral Review PHP Chapter

Source: Internet
Author: User
Tags echo date flock
PHP Technician--Interview summary PHP
1. Realize Chinese string interceptionNo garbled method
Open the mbstring extension, and then customize the function:

 

2. Print the day before using PHP


  

3, does not apply the third variable Exchange 2 variables value


   

4. Convert 1234567890 to 1,234,567,890


Header (' Content-type:text/html:charset=utf-8 '); $str = ' 1234567890 ';//invert string $str = Strrev ($STR);//Comma separated by 098, 765,432,1, $str = Chunk_split ($str, 3, ', ');//Invert $str = Strrev ($STR);//Remove Left, $str = LTrim ($str, ', '); Echo $str;


5. Implement UTF8 string inversion
Cannot use Strrev, Chinese will be wrong


function Strrev_utf8 ($STR) {return join ("", Array_reverse (Preg_split ("//u", $str)));} $str = "I am a good boy"; Echo Strrev_utf8 ($STR); 6, take the file extension of the URL, as many as possible to implement the method $str = "www.baidu.com/index.php"; function Get_ext1 ( $STR) {return strrchr ($str, '. ');} function Get_ext2 ($str) {return substr ($str, Strrpos ($str, '. '));} function Get_ext3 ($str) {$str = PathInfo ($STR); return $str [' extension '];} function Get_ext4 ($str) {$arr = explode ('. ', $str); return $arr [Count ($arr)-1];} function Get_ext5 ($str) {$pattern = '/^[^\.] +\. ([\w]+) $/'; return preg_replace ($pattern, ' ${1} ', basename ($STR));}


7. Write a function to convert the string Open_door to Opendoor


$str = "Open_door", function Change_str ($str) {$arr = explode (' _ ', $str); $arr = Array_map (' Ucfirst ', $arr); return implode ( ", $arr);} echo Change_str ($STR);


8. Single case mode


    

10. Get the file name extension from a completed URL


     

11. Write a function to facilitate all files and subfolders under a folder
      

12. The principle of unlimited classification in the forum
First design the database table


CREATE TABLE category (cate_id int unsigned not NULL auto_increment primary key,cat_name varchar (in) NOT null default ', PA rent_id int unsigned NOT NULL default 0) Engine=innodb Charset=utf8; then recursive implementation with function, infinite classification function tree ($arr, $pid =0, $level =0) { Static $list = Array (), foreach ($arr as $v) {//If it is a top-level classification, then $list//the node as the root and traverse its child node if ($v [' parent_id '] = = $pid) {$v [' Level '] = $level; $list [] = $v; tree ($arr, $v [' cat_id '], $level + 1);}} return $list;}


13, calculate the relative path of 2 files
 
        1) {$i + = 1; $head = Array_shift ($monkey);//Dequeue the first if ($i% $m! = 0) {//If it is not a multiple of M, return the tail, otherwise Array_push ($monkey, $head);}} return $monkey [0];} echo King (10,7);


15, PHP implementation of two-way queue
 
        

I hope this article on the vastPHP DeveloperHelpful, thanks for reading this article.
  • 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.