-4

Can someone tell me what is wrong with this code?

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

This is the error message:

opendir(/app/$user/) [function.opendir]: failed to open dir: No such file or directory in
Flame Trap
  • 2,745
  • 1
  • 20
  • 33

3 Answers3

3

Double quotes to evaluate variables

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

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

Community
  • 1
  • 1
Mike B
  • 31,390
  • 13
  • 83
  • 110
1

In single quotes $user will not be interpreted as a variable - in double quotes it will be try opedir("/users/$user")

Murray McDonald
  • 631
  • 4
  • 5
1

try this:

$handle = opendir("/users/$user/");
magicianiam
  • 1,352
  • 6
  • 31
  • 64