将变量放入 PHP Glob 函数
Putting Variable in PHP Glob Function
这看起来应该很容易,但我尝试过的都没有奏效。
$glob = glob("{04-19-2017,04-20-2017,04-21-2017}/*.xml", GLOB_BRACE);
完美运行。
但我的做法是使用 _GET
动态生成 $date
变量。
我试过了...
$date = '04-19-2017,04-20-2017,04-21-2017';
// failed glob attempts
$glob = glob("{'.$date.'}/*.xml", GLOB_BRACE);
$glob = glob("{$date.}/*.xml", GLOB_BRACE);
$glob = 'glob("{' . $date . '}/*.xml"', GLOB_BRACE);
就像我说的,这应该非常简单,但我 运行 没有想法:/
如何获取其中的变量?
$glob = glob("{$date}/*.xml", GLOB_BRACE);
或
$glob = glob('{'.$date.'}/*.xml', GLOB_BRACE);
如果您在 " "
之间放置一个变量,将使用该变量
如果您在 ' '
之间放置一个变量,该变量将作为字符串处理
What is the difference between single-quoted and double-quoted strings in PHP?
这看起来应该很容易,但我尝试过的都没有奏效。
$glob = glob("{04-19-2017,04-20-2017,04-21-2017}/*.xml", GLOB_BRACE);
完美运行。
但我的做法是使用 _GET
动态生成 $date
变量。
我试过了...
$date = '04-19-2017,04-20-2017,04-21-2017';
// failed glob attempts
$glob = glob("{'.$date.'}/*.xml", GLOB_BRACE);
$glob = glob("{$date.}/*.xml", GLOB_BRACE);
$glob = 'glob("{' . $date . '}/*.xml"', GLOB_BRACE);
就像我说的,这应该非常简单,但我 运行 没有想法:/
如何获取其中的变量?
$glob = glob("{$date}/*.xml", GLOB_BRACE);
或
$glob = glob('{'.$date.'}/*.xml', GLOB_BRACE);
如果您在 " "
之间放置一个变量,将使用该变量
如果您在 ' '
之间放置一个变量,该变量将作为字符串处理
What is the difference between single-quoted and double-quoted strings in PHP?