opendir php错误与变量

时间:2012-03-23 17:06:50

标签: php function opendir

有人可以告诉我这段代码有什么问题吗?

<?php
    $user = $fgmembersite->UserFullName();
    $handle = opendir('/users/$user/');
?>

这是错误消息:

opendir(/app/$user/) [function.opendir]: failed to open dir: No such file or directory in

3 个答案:

答案 0 :(得分:3)

评估变量的双引号

$handle = opendir("/users/$user/");

What is the difference between single-quoted and double-quoted strings in PHP?

答案 1 :(得分:1)

在单引号中,$ user不会被解释为变量 - 在双引号中它将是try opedir(“/ users / $ user”)

答案 2 :(得分:1)

试试这个:

$handle = opendir("/users/$user/");