php foreach和glob()函数

编程入门 行业动态 更新时间:2024-10-25 06:33:41
本文介绍了php foreach和glob()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

PHP版本5.2.*

PHP versione 5.2.*

我的功能不起作用:/

服务器中的图像,在以下文件夹中:/public_html/gallery/images

images in server, in folder: /public_html/gallery/images

<?php foreach(glob('gallery/images/*', GLOB_NOSORT) as $image) { echo "Filename: " . $image . "<br />"; } ?>

有什么帮助吗?我在做什么错?

any help? what im doing wrong?

我得到的错误是:警告:在第2行的/home/a9773555/public_html/gallery/index.php中为foreach()提供了无效的参数

error i get is : Warning: Invalid argument supplied for foreach() in /home/a9773555/public_html/gallery/index.php on line 2

推荐答案

问题似乎是您已将php文件放在gallery文件夹中.

The problem looks you have put your php file in gallery folder...

/home/a9773555/public_html/gallery/index.php

/home/a9773555/public_html/gallery/index.php on line 2

如果是这种情况(如果您将index.php放在图库中),请尝试以下操作:

if that is the case (if you put index.php in gallery) then try the following:

<?php foreach(glob('images/*', GLOB_NOSORT) as $image) { echo "Filename: " . $image . "<br />"; } ?>

或执行以下操作,

将index.php放在/home文件夹中.然后...

Put your index.php in your /home folder. then...

<?php foreach(glob('a9773555/public_html/gallery/images/*', GLOB_NOSORT) as $image) { echo "Filename: " . $image . "<br />"; } ?>

尝试一下.让我知道...

Give it a try. and let me know...

更多推荐

php foreach和glob()函数

本文发布于:2023-10-07 14:39:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469656.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   php   foreach   glob

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!