Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Project 1 - PHP coding

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
sirobert



Joined: Wed Jul 21, 2010 7:37 am
Posts: 2

PostPosted: Wed Jul 21, 2010 7:51 am    Post subject: Project 1 - PHP coding Reply with quote

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);

?>
Back to top
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Wed Jul 21, 2010 8:31 am    Post subject: Re: Project 1 - PHP coding Reply with quote

sirobert wrote:
nothing is written to the output file.


I assume you are talking about
Code:

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
Back to top
View user's profile Send private message
sirobert



Joined: Wed Jul 21, 2010 7:37 am
Posts: 2

PostPosted: Wed Jul 21, 2010 10:57 am    Post subject: PHP Project 1 Reply with quote

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
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast