Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: RecursiveIteratorIterator::setMaxDepth - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: RecursiveIteratorIterator::setMaxDepth

2025-06-07

RecursiveIteratorIterator::setMaxDepth

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

RecursiveIteratorIterator::setMaxDepthSet max depth

说明

public RecursiveIteratorIterator::setMaxDepth(int $maxDepth = -1): void

Set the maximum allowed depth.

警告

本函数还未编写文档,仅有参数列表。

参数

maxDepth

The maximum allowed depth. -1 is used for any depth.

返回值

没有返回值。

错误/异常

Emits an Exception if maxDepth is less than -1.

添加备注

用户贡献的备注 2 notes

up
1
Anonymous
5 years ago
to only access the current folder:
$max_depth = 0;
up
1
Anonymous
5 years ago
I didn't understand what to do with this statement:

RecursiveIteratorIterator::setMaxDepth ([ int $max_depth = -1 ] ) : void

So, after finding the answer, this is how you incorporate it (for anyone else who was stuck for a while like me!):

// define the depth of the tree to which you want to search
// where -1 = show all layers below the parent
// and 1 = show the first layer, etc, etc
$max_depth = -1;

// set the path to the directory
$this_directory

// do the search
$recursive = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this_directory));

// now adjust the contents to your desired depth
$recursive->setMaxDepth($max_depth);

官方地址:https://www.php.net/manual/en/recursiveiteratoriterator.setmaxdepth.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3