Project 1 - PHP coding

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Project 1 - PHP coding

Postby sirobert » Wed Jul 21, 2010 6:51 am

I'm attempting the first php project, but the output to buffer commands arn't working. The files are still output to the command line, nothing is written to the output file. What am I doing wrong?

Thanks
Simon

<?php


function subdir_scan($dir){
$files = scandir($dir);


foreach ($files as $file){
if($file==".") continue;
if($file=="..") continue;
print "$dir/$file\n";

if(is_dir("$dir/$file")){
subdir_scan("$dir/$file");
}
}
}
chdir("..");
ob_start;
subdir_scan(".");
$output=ob_get_clean();
echo $output;
file_put_contents("output",$output);

?>
sirobert
 
Posts: 2
Joined: Wed Jul 21, 2010 6:37 am

Re: Project 1 - PHP coding

Postby bobthebob1234 » Wed Jul 21, 2010 7:31 am

sirobert wrote:nothing is written to the output file.


I assume you are talking about
Code: Select all
file_put_contents("output",$output);


Does the user you are running the script as have permission to write to the file 'output'?

If the file 'output' doesn't exist does the user have permission to create and write a file?
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
User avatar
bobthebob1234
LXF regular
 
Posts: 1372
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

PHP Project 1

Postby sirobert » Wed Jul 21, 2010 9:57 am

yup, running the script as me and the owner and group is me. I think it might be something to do with the output buffer commands as the instructions say that the output to the screen should be suppressed if its going to the buffer.

Thanks
sirobert
 
Posts: 2
Joined: Wed Jul 21, 2010 6:37 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests