PHP Development (-callback-readdir-is_dir-foreach-glob-phpstorm)

Source: Internet
Author: User
Tags glob
PHP Development (-callback-readdir-is_dir-foreach-glob-phpstorm)



<?php/** * Callback callback function */echo "----------callback Demo 1----------<br>"; Call_user_func_array ("Fun", Array (123,321)); Printed results: 123, 321, 3 Call_user_func_array ("Fun", Array (123,321,444,555));    Printed results: 123, 321, 444 function fun ($one = "1", $two = "2", $three = "3") {echo "$one, $two, $three <br>"; /** * Exclude palindrome Number * palindrome number: n digits, 1th and last n digits * Strrev Reverse String */echo "----------callback Demo 2--------    --<br> "; Demo ("Test"); Printed results: 10 12 13 14 15 16 17 18 19 20 21 23 24//Not print Palindrome number: 0 1 2 3 4 5 6 7 8 9 each echo "<br&    gt; ";                function Demo ($num, $n) {for ($i =0; $i < $num; $i + +) {if (Call_user_func_array ($n, Array ($i)))            Continue        echo $i. "";        }} function Test ($i) {if ($i ==strrev ($i)) return true;    else return false; }/** * */echo "----------callback Demo 3----------<Br> "; $filter = new filter (); Instantiate filter//$filter->one (1); Call the one function inside the Filter class//filter::two (1); Call the one of the static functions//functions within the Filter class to exclude the 3 integer multiple demo (25,array (New Filter (), "one");    Printed results: 1 2 4 5 7 8 + + + echo "<br>"; The static function of both excludes all numeric demos containing the string 3 ("Filter", "25,array");    Printed results: 0 1 2 4 5 6 7 8 9-Each of the "<br>";            Class filter{function One ($i) {if ($i% 3 = = 0) {return true;            } else {return false;            }} static function ($i) {if (Preg_match ('/3/', $i)) {return true;            }else{return false; }}}/** * Test Folder command, just look for a program to copy the installation directory under the project * Traverse all directories and files in the specified directory * READDIR () function returns the filename of the next file in the directory * Is_dir  () to determine if the given file name is a directory * Readdir print result:.  Current directory * Readdir print results:. Previous directory */echo "----------Opendir----------<br> ";    $dirname = "./demofile2";    Open Directory Resource $dir = Opendir ($dirname); Read file echo readdir ($dir). '    <br> '; echo Readdir ($dir). '    <br> '; echo Readdir ($dir). '    <br> '; while ($file = Readdir ($dir)) {$file = $dirname. "        /". $file;        if (Is_dir ($file)) {echo "directory:";        }else{echo "File:"; } echo $file. '    <br> ';    }//Close directory Resource Closedir ($DIR);      /** * Test Folder command, just look for a program to copy the installation directory under the project * Traverse all directories and files (including subdirectories) in the specified directory * glob returns a file name or directory that matches the specified pattern * Glob returns an array containing matching files/directories * The foreach syntax structure provides a simple way to iterate through an array * foreach (array_expression as $value) in each loop, the value of the current cell is assigned to $value and the pointer inside the array moves forward one step * (so    The next cell will be in the next loop) */echo "----------Opendir2----------<br>";    Fetchdir ("DemoFile1"); function Fetchdir ($dir) {foreach (Glob ($dir. ' \* ') as $file) {echo $file. '            <br> ', ' \ n ';            if (Is_dir ($file)) {Fetchdir ($file); }}} FetchdIr2 ("DemoFile1"); function FetchDir2 ($dir) {foreach (Glob ($dir. ' \* ') as $file) {if (Is_dir ($file)) {echo " Directory: ". $file. '                <br> ', ' \ n ';            FetchDir2 ($file); }else{echo "File:". $file. '            <br> ', ' \ n '; }        }    }

The above is the PHP development (-callback-readdir-is_dir-foreach-glob-phpstorm) content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.