⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 08c04-1.php

📁 介绍PHP5的给类型函数应用
💻 PHP
字号:
<?php// A function that will traverse a directory tree, looking for files// that match a given regular expression, and returns all files:function find($regex, $dir) {    $matches = array();        // Ok, open up the directory and prepare to start looping:    $d = dir($dir);    // Loop through all the files:    while (false !== ($file = $d->read())) {        // Skip . and .., we don't want to deal with them.        if (($file == '.') || ($file == '..')) { continue; }        // If this is a directory, then:        if (is_dir("{$dir}/{$file}")) {            // Call this function recursively to look in that subdirectory:            $submatches = find($regex, "{$dir}/{$file}");            // Add them to the current match list:            $matches = array_merge($matches, $submatches);        } else {            // It's a file, so check to see if it is a match:            if (preg_match($regex, $file)) {                // Add it to our array:                $matches[] = "{$dir}/{$file}";            }        }    }        // Ok, that's it, return the array now:    return $matches;}// Look for all PHP files on your website, starting with the document root:$found = find('/\.php$/', $_SERVER['DOCUMENT_ROOT']);// Sort, then Display them:sort($found);echo '<pre>', print_r($found, true), '</pre>';?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -