简体   繁体   English

在Magento中使用scandir()

[英]Using scandir() with Magento

For the home page of my Magento store, I am using a basic gallery script which scans a predefined directory using scandir() and outputs each filename to be displayed in the gallery. 对于我的Magento商店的主页,我使用一个基本的库脚本,该脚本使用scandir()扫描预定义的目录,并输出要在库中显示的每个文件名。

Everything works ok on my local machine, but the script seems to ignore the scandir() and just proceeds as normal without any errors or warnings. 一切在我的本地计算机上都可以正常运行,但是脚本似乎忽略了scandir(),只是正常进行而没有任何错误或警告。 If I replace the scandir() and input the filenames directly, the gallery script works fine. 如果我替换scandir()并直接输入文件名,则库脚本可以正常工作。

What is going wrong here? 这是怎么了?

Hard to tell without seeing your code in context, but my guess if scandir is returning an empty array, probably because you're not passing it what you think you're passing it. 很难在上下文scandir不到代码的情况下很难分辨,但是我猜测scandir是否返回一个空数组,可能是因为您没有传递它,而是认为传递了它。 Add some debugging to your calls to scandir 在对scandir的调用中添加一些调试功能

$path;
var_dump($path);

$results = scandir($path);
var_dump($results);

and you should have a better idea of whats going on. 并且您应该对发生的事情有更好的了解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM