Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/File-input-output/PHP/file-input-output-1.php
Normal file
18
Task/File-input-output/PHP/file-input-output-1.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
if (!$in = fopen('input.txt', 'r')) {
|
||||
die('Could not open input file.');
|
||||
}
|
||||
|
||||
if (!$out = fopen('output.txt', 'w')) {
|
||||
die('Could not open output file.');
|
||||
}
|
||||
|
||||
while (!feof($in)) {
|
||||
$data = fread($in, 512);
|
||||
fwrite($out, $data);
|
||||
}
|
||||
|
||||
fclose($out);
|
||||
fclose($in);
|
||||
?>
|
||||
9
Task/File-input-output/PHP/file-input-output-2.php
Normal file
9
Task/File-input-output/PHP/file-input-output-2.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
if ($contents = file_get_contents('input.txt')) {
|
||||
if (!file_put_contents('output.txt', $contents)) {
|
||||
echo('Could not write output file.');
|
||||
}
|
||||
} else {
|
||||
echo('Could not open input file.');
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue