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