This commit is contained in:
parent
c07e554646
commit
f1107da3b5
|
@ -78,3 +78,5 @@ fabric.properties
|
|||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
/tmp/
|
||||
/data/test_write
|
||||
/upload/
|
||||
|
|
57
13.test1.php
57
13.test1.php
|
@ -1 +1,58 @@
|
|||
<?php
|
||||
$readfile = readfile('data/read_test_file');
|
||||
if (!$readfile)
|
||||
echo '文件读取失败';
|
||||
|
||||
echo '<br>';
|
||||
|
||||
$file_array = file('data/read_test_file');
|
||||
if (!$file_array) {
|
||||
echo '文件读取失败';
|
||||
return;
|
||||
}
|
||||
foreach ($file_array as $item)
|
||||
echo $item . '<br>';
|
||||
|
||||
echo '<br>';
|
||||
|
||||
$file_get_contents = file_get_contents('data/read_test_file');
|
||||
if ($file_get_contents === false) {
|
||||
echo '文件读取失败';
|
||||
return;
|
||||
}
|
||||
echo $file_get_contents;
|
||||
|
||||
echo '<br>';
|
||||
|
||||
$resource = fopen('data/fun.php', 'rb');
|
||||
while (!feof($resource)) {
|
||||
echo fgets($resource);
|
||||
}
|
||||
rewind($resource);
|
||||
|
||||
echo '<br>';
|
||||
|
||||
while (!feof($resource)) {
|
||||
// echo fgetss($resource,,) // fgetss function is removed in php8
|
||||
// echo strip_tags(fgets($resource));
|
||||
echo htmlspecialchars(fgets($resource), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
fclose($resource);
|
||||
|
||||
echo '<br>';
|
||||
|
||||
$resource1 = fopen('data/read_test_file', 'rb');
|
||||
while (($char = fgetc($resource1)) !== false) {
|
||||
echo $char;
|
||||
}
|
||||
rewind($resource1);
|
||||
|
||||
echo '<br>';
|
||||
|
||||
echo fread($resource1,30).'<br>'; //中文占3字节
|
||||
echo fread($resource1,filesize('data/read_test_file'));
|
||||
fclose($resource1);
|
||||
|
||||
echo '<br>';
|
||||
|
||||
|
||||
|
|
11
13.test2.php
11
13.test2.php
|
@ -1 +1,12 @@
|
|||
<?php
|
||||
$filepath = 'data/test_write';
|
||||
$str = '你好世界hello world<br>';
|
||||
$resource = fopen($filepath, 'w+b') or die('文件不存在');
|
||||
fwrite($resource, $str);
|
||||
//rewind($resource);
|
||||
//echo htmlspecialchars(fgets($resource));
|
||||
fclose($resource);
|
||||
readfile($filepath);
|
||||
|
||||
file_put_contents($filepath,$str);
|
||||
readfile($filepath);
|
11
13.test3.php
11
13.test3.php
|
@ -1 +1,12 @@
|
|||
<?php
|
||||
$path = 'data';
|
||||
if(is_dir($path)){
|
||||
$resource = opendir($path) or die('目录打开失败');
|
||||
// echo $resource;
|
||||
$scandir = scandir($path);
|
||||
foreach ($scandir as $item){
|
||||
echo $item.'<br>';
|
||||
}
|
||||
}else{
|
||||
echo '文件夹路径不存在';
|
||||
}
|
|
@ -1 +1,9 @@
|
|||
<?php
|
||||
$resource = @opendir('ftp://chenx221:chenx221@dl.chenx221.cyou:21');
|
||||
if ($resource === false) {
|
||||
die('无法打开目录');
|
||||
}
|
||||
while (false !== ($entry = readdir($resource))) {
|
||||
echo "$entry\n";
|
||||
}
|
||||
closedir($resource);
|
19
13.test5.php
19
13.test5.php
|
@ -1 +1,20 @@
|
|||
<?php
|
||||
$filename = "data/07.txt";
|
||||
$total = filesize($filename);
|
||||
if (is_file($filename)) {
|
||||
echo "文件总字节数:" . $total . "<br>";
|
||||
$fopen = fopen($filename, 'rb');
|
||||
echo "初始指针位置是:" . ftell($fopen) . "<br>";
|
||||
fseek($fopen, 30);
|
||||
// 07.txt原先是UTF-8 with BOM编码,现在已经转换为UTF-8编码,故不需要33
|
||||
echo "使用fseek()函数后指针位置:" . ftell($fopen) . "<br>";
|
||||
echo "输出当前指针后面的内容:" . fgets($fopen) . "<br>";
|
||||
if (feof($fopen))
|
||||
echo "当前指针指向文件末尾:" . ftell($fopen) . "<br>";
|
||||
rewind($fopen);
|
||||
echo "使用rewind()函数后指针的位置:" . ftell($fopen) . "<br>";
|
||||
echo "输出前31字节的内容:" . fgets($fopen, 31);
|
||||
fclose($fopen);
|
||||
} else {
|
||||
echo "文件不存在";
|
||||
}
|
|
@ -1 +1,8 @@
|
|||
<?php
|
||||
$filename = 'data/08.txt';
|
||||
$fopen = fopen($filename, 'w');
|
||||
flock($fopen,LOCK_EX);
|
||||
fwrite($fopen,'hello world');
|
||||
flock($fopen,LOCK_UN);
|
||||
fclose($fopen);
|
||||
readfile($filename);
|
22
13.work1.php
22
13.work1.php
|
@ -1 +1,21 @@
|
|||
<?php
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>test1</title>
|
||||
</head>
|
||||
<body>
|
||||
你好,你是第<span><?php
|
||||
$filename = 'data/counter.txt';
|
||||
$fopen = fopen($filename, 'c+');
|
||||
flock($fopen, LOCK_EX);
|
||||
$counter = intval(trim(fgets($fopen)));
|
||||
$counter++;
|
||||
ftruncate($fopen, 0);
|
||||
rewind($fopen);
|
||||
fwrite($fopen, strval($counter));
|
||||
flock($fopen, LOCK_UN);
|
||||
fclose($fopen);
|
||||
echo $counter;
|
||||
?></span>位访客
|
||||
</body>
|
|
@ -1 +1 @@
|
|||
柔情似水 佳期如梦 忍顾鹊桥归路 两情若是久长时 又岂在朝朝暮暮
|
||||
柔情似水 佳期如梦 忍顾鹊桥归路 两情若是久长时 又岂在朝朝暮暮
|
|
@ -0,0 +1 @@
|
|||
hello world
|
|
@ -0,0 +1 @@
|
|||
167
|
46
data/fun.php
46
data/fun.php
|
@ -1,10 +1,36 @@
|
|||
<table width="200" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td height="20" align="center" valign="middle" scope="col"><font color='red'>I am red.</font></td>
|
||||
<td height="20" align="center" valign="middle" scope="col"><font color='green'>I am green.</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20" align="center" valign="middle"><font color='black'>I am black.</font></td>
|
||||
<td height="20" align="center" valign="middle"><font color='pink'>I am pink. </font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<style>
|
||||
.red-text {
|
||||
color: red;
|
||||
}
|
||||
.green-text {
|
||||
color: green;
|
||||
}
|
||||
.black-text {
|
||||
color: black;
|
||||
}
|
||||
.pink-text {
|
||||
color: pink;
|
||||
}
|
||||
.table-style {
|
||||
width: 200px;
|
||||
border: 0;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.cell-style {
|
||||
height: 20px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
<table class="table-style">
|
||||
<tr>
|
||||
<td class="cell-style"><span class="red-text">I am red.</span></td>
|
||||
<td class="cell-style"><span class="green-text">I am green.</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell-style"><span class="black-text">I am black.</span></td>
|
||||
<td class="cell-style"><span class="pink-text">I am pink.</span></td>
|
||||
</tr>
|
||||
</table>
|
|
@ -0,0 +1,4 @@
|
|||
hello world
|
||||
你好世界
|
||||
test
|
||||
123456
|
Loading…
Reference in New Issue