PHP入門–fread() でファイルを読み取るソースサンプル

サンプル1
<?php
$filename = “/var/www/st24.txt";
$ctlp = fopen($filename, “r");

$contents = fread($ctlp, filesize ($filename));
fclose($ctlp);
?>

サンプル2
<?php
$ctlp = fopen('http://www.example.com’, 'r’);
$content = ";
while(!feof($ctlp)){
$content .= fread($ctlp, 8192);
}
echo $content;
fclose($ctlp);
?>

サンプル3
<?php
$ctlp= fopen('http://www.example.com’, 'r’);
$content = ";
while(false != ($cf = fread($handle, 8192))){
$content .= $cf;
}
echo $content;
fclose($ctlp);
?>

PHP

Posted by arkgame