【发布时间】:2013-10-14 05:22:36
【问题描述】:
我有一段代码:
foreach (glob('mov/$context.mov') as $filename){
$theData = file_get_contents($filename) or die("Unable to retrieve file data");
}
这是在该 glob 中添加变量的正确方法吗? $上下文
另外,在我的新文件中,我想用 $context 替换一个单词,所以我会写
$context = "word"; // so it adds that word to the glob function when the script is included in a different file.
【问题讨论】:
-
如果要使用
glob中的变量值,请使用双引号而不是单引号。 -
@bwoebi:
Is that the correct way to add a variable within that glob? $context-- 你错过了这部分吗?