Search code examples
phpfunctionopendir

opendir php error with variables


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

Solution

  • Double quotes to evaluate variables

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

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