unexpected include parse error

From: Date: Tue, 27 Jan 2004 04:27:07 +0000
Subject: unexpected include parse error
Groups: php.general 
Request: Send a blank email to php-general+get-175845@lists.php.net to get a copy of this message
I'm new so probably missing something easy or doing something terribly wrong but I have spent a lot of time experimenting... <?php $dirstr= "./" include 'scandir.php'; scandir('$dirstr'); ?> parse error, unexpected T_INCLUDE in [the above file] if I comment out the $dirstr= "./" above that error goes away and the scandir.php include runs (that's a php5 function that needs to be defined manually in PHP 4.3.4) #scandir.php <?php #$dirstr=".\"; function scandir($dirstr) {
     $files = array();
     $fh = opendir($dirstr);
     while (false !== ($filename = readdir($fh))) {
         array_push($files, $filename);
     }
     closedir($fh);
     return $files;
} ?> If I set $dirstr=".\"; in the function it gives these errors:
Parse error: unexpected $end in scandir.php at    ?> last line
Fatal error: Call to undefined function: scandir() in showdir.php If I don't set $dirstr at all, it runs the scandir function and fouls up in expected ways: Warning: opendir($dirstr): failed to open dir: Invalid argument in scandir.php Warning: readdir(): supplied argument is not a valid Directory resource in scandir.php Warning: closedir(): supplied argument is not a valid Directory resource in scandir.php

« previous php.general (#175845) next »