Test various PHP magic methods

1 name = $ name; 12} 13 14 # automatically call this method when ECHO outputs the class 15 public function _ tostring () {16 return $ this-> name; 17} 18} 19 20 class man {21 private $ name; 22 private $ age; 23 private $ son; 24 25 Public Function

PHP searches for the maximum and minimum values in an array.

$arr[$i]) { $cmpTime++; if($small > $arr[$i]) { $small = $arr[$i]; } } else { $big = $arr[$i]; } } echo "ArrLeng: "

_ Clone () in PHP ()

PHP's _ clone () method is used to perform a shortest copy on an object instance. The basic value type in the object is copying the data transfer value, and the object type member variable in the object, if you do not overwrite the _ clone method

PHP directly select sorting

Select the average sorting efficiency directly. The best case is that the worst case is O (n ^ 2) 1 $ arr [$ J]) $ min1_= $ J; 9 $ TMP = $ arr [$ I]; 10 $ arr [$ I] = $ arr [$ min1_]; 11 $ arr [$ min1_] = $ TMP; 12} 13} 14 return $ arr; 15} 16 17

PHP obtains class source code through reflection

1 getfilename (); # Get the script file name 4 $ file = file ($ PATH ); # The file () method gets the file content and saves the content in an array. Each element of the array saves a row of content 5 $ start = $ ref-> getstartline (); # obtain the

PHP quick sorting

Average efficiency o (nlogn) of the fast sort, preferably O (nlogn). The worst case is that when the array is ordered, it degrades to O (N ^ 2) 1 =$ arr [$ start] & $ low! = $ High) {17 -- $ high; 18} 19 $ temp = $ arr [$ low]; 20 $ arr [$ low] = $

Implement the mb_substr function in PHP.

1 ". mymbsubstr ($ STR, 0, 7, "utf8 "). ""; 20 echo mb_substr ($ STR, 0, 7, "utf8"); 21?> Output Array (1) {[0] => array (8) {[0] => string (1) "I" [1] => string (1) "'" [2] => string (1) "M" [3] => string (1) "" [4] => string (1) "A" [5] =>

PHP uses reflection to dynamically load third-party classes

Loading third-party classes with reflection is useful in: Configure the class to be loaded using XML or other configuration files to separate the class from the system source code. Performs a class check on the loaded class. The loaded class

[Reprint] PHP database data dictionary export script

1 7 */8 9 // configure Database 10 $ dbserver = "localhost "; 11 $ dbusername = "root"; 12 $ dbpassword = "root"; 13 $ database = 'mydb'; 14 // other configuration 15 $ Title = 'System data dictionary '; 16 17 $ mysql_conn = @ mysql_connect ("$

PHP anonymous functions and Java Anonymous class applications

In general, anonymous functions and anonymous classes are used for callback, because you may not know the specific implementation of callback functions or methods and may need to change according to the actual situation, in addition, anonymous

PHP binary Addition

1 = 0; $ I --) {23 $ result = $ bin_arr1 [$ I] + $ bin_arr2 [$ I] + $ carry; 24 switch ($ result) {25 case 0: 26 array_unshift ($ sum_arr, 0); 27 $ carry = 0; 28 break; 29 case array_unshift ($ sum_arr, 1); 31 $ carry = 0; 32 break; 33 Case 2: 34

PHP output cache (output_buffering) note-doubts

First, clarify the PHP output sequence 1. Open the PHP output cache: ECHO, print-> PHP output_buffring-> server buffering-> browser buffering-> Browser display 2. php output cache not enabled: ECHO, print-> server buffering-> browser buffering->

Implementation of PHP priority queue

The priority queue is actually the largest heap, mainly for some adjustments to the operation of the largest heap 1 $ arr [$ max_inx]) {23 $ max_inx = $ left_inx; 24} 25 26 if ($ rig_hour $ arr [$ max_hour]) {# Adjust right Child 27 $ max_0000= $

PHP short connection generation

1 5; 26} 27 28 $ short_url_list [] = $ short_url; 29} 30 31 return $ Short_url_list; 32} 33} 34 35 $ url = "http://www.cnblogs.com/zemliu/"; 36 $ short = short_url: Short ($ URL); 37 print_r ($ short); 38?> Array ([0] => http://t.cn/KyfLyH [1] =>

PHP base sorting (count sorting implementation)

1 =0; $ I --) {36 $ sorted_arr [$ time_arr [$ arr_temp [$ I]-1] = $ arr [$ I]; 37 $ time_arr [$ arr_temp [$ I] --; 38} 39 40 $ arr = $ sorted_arr; 41 ksort ($ ARR ); # ignore the efficiency loss of key sorting this time 42} 43 44 # Calculate a

PHP tree first, middle, and backward Traversal

1 val = $ val; 10} 11} 12 13 # first traverse 14 function pretraverse (node $ root) {15 echo $ root-> Val. ""; 16 if ($ root-> LC! = NULL) pretraverse ($ root-> Lc); 17 if ($ root-> RC! = NULL) pretraverse ($ root-> RC); 18} 19 20 # traverse 21

PHP two-way queue with Sentinel

1 next; 14 While ($ cNode! ==$ List & $ cNode-> key! ==$ Key) {15 $ cNode = $ cNode-> next; 16} 17 18 if ($ cNode ===$ list) {19 Return false; 20} else {21 return $ cNode; 22} 23} 24 25 # insert node 26 function insert ($ list, $ new_node) {27 $

Proxy mode of PHP

Similarities and differences between proxy mode and parent class and Interface Similarities: The Role of the proxy mode is similar to that of the parent class and interfaces and combinations. It aims to aggregate the shared part and reduce the

PHP step jumping Problem

1 2, there are two possible situations. The first is the first hop level 1, and the remaining hop method is F (n-1) 6 # The second is the first hop Level 2, so the rest of the hop method is F (n-2), then f (n) = f (n-1) + f (n-2) 7 # so there is a

PHP String Matching Algorithm Sunday Algorithm

Search Text text = "My Testing Algorithm in test" Pattern = "test" The key aspect of the Sunday algorithm is 1. set a shift [] matching shift ing. The shift [] ing relationship must start from left to right. For example, pattern = "test". Note that

Total Pages: 12780 1 .... 10371 10372 10373 10374 10375 .... 12780 Go to: GO

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.