File input/output: Difference between revisions

Content added Content deleted
(Added Go)
Line 1,021:
<lang php><?php
 
if (!$in = fopen('input.txt', 'r')) {
die('Could not open input file.txt!');
}
 
if (!$out = fopen('output.txt', 'w')) {
die('Could not open output file.txt!');
}
 
while (!feof($in)) {
$data = fread($in, 512);
fwrite($out, $data);
}
 
Line 1,040:
{{works with|PHP|5}}
<lang php><?php
if( ($contents = file_get_contents('input.txt') ) {
if if( !file_put_contents('output.txt', $contents) ) echo('could not write output file');{
echo('couldCould not openwrite inputoutput file.');
}else{
}
echo('could not open input file');
} else {
echo('Could not open input file.');
}
?></lang>