simple functions

<?php
$docRoot = $_SERVER['DOCUMENT_ROOT'];
//readfile($docRoot."/orders/order.txt"); //do not need fopen
unlink($docRoot."/orders/order.txt");
$fp = fopen($docRoot."/orders/orders.txt",rb);
if($fp){
echo "open ok";
}else{
echo 'error';
}
while (!feof($fp)){
echo fgetc($fp);
}
//fpassthru($fp); //out put string needs fopen
//$len = fwrite($fp,'12345',3);
rewind($fp);
fseek();
fclose($fp);
//file_put_contents($docRoot/orders/order.txt,'123',FILE_APPEND);

Examples

<?php
// create short variable name
$document_root = $_SERVER['DOCUMENT_ROOT'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Bob's Auto Parts - Customer Orders</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Customer Orders</h2>
<?php
@$fp = fopen("$document_root/orders/Book1.csv", 'rb');
flock($fp, LOCK_SH); // lock file for reading if (!$fp) {
echo "<p><strong>No orders pending.<br />
Please try again later.</strong></p>";
exit;
} while (!feof($fp)) {
$order= fgets($fp);
echo htmlspecialchars($order)."<br />";
} flock($fp, LOCK_UN); // release read lock echo 'Final position of the file pointer is '.(ftell($fp));
echo '<br />';
rewind($fp);
echo 'After rewind, the position is '.(ftell($fp));
echo '<br />'; // while (!feof($fp)) {
//
// $s= fgetcsv($fp,9,',');
// echo "<pre>";
// var_dump($s);
// } if(is_null($s)) {
echo 'null';
}
fclose($fp); ?>
</body>
</html>

PHP Files functions的更多相关文章

  1. Creating Your Own PHP Helper Functions In Laravel

    By Hamza Ali LAST UPDATED AUG 26, 2018  12,669 104 Laravel provides us with many built-in helper fun ...

  2. kickstart部署及使用

    Linux运维:kickstart : 矮哥linux运维群:93324526 1.环境检查 [root@m01 ~]# cat /etc/redhat-release CentOS release ...

  3. KICKSTART无人值守安装

    1.1 环境说明 [root@test ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@test ~]# uname -r - ...

  4. kickstart无人值守

    笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 高逼格装系统的方法 Kickstar Cobbler 注意,kickstart并不是一个服务的名称,只是装系统的方 ...

  5. Linux系统优化脚本

    #!/bin/bash ############################################################################## # File Na ...

  6. kickstart ---无人值守安装

    kickstart 实战 http://man.linuxde.net/download/CentOS_6_9镜像 安装: 关闭防火墙 且在编辑虚拟网络的vnet8中要取消使用本地dhcp项 1.yu ...

  7. s32 kickstart 批量自动安装系统

    1. 自动安装操作系统 http://blog.oldboyedu.com/autoinstall-kickstart/   自动安装操作系统的解决方案:kickstart.cobbler(披着web ...

  8. Kickstart无人值守安装[转载]

    导言 作为中小公司的运维,经常会遇到一些机械式的重复工作,例如:有时公司同时上线几十甚至上百台服务器,而且需要我们在短时间内完成系统安装. 常规的办法有什么? 光盘安装系统===>一个服务器DV ...

  9. kickstart安装步骤

    1.1 环境说明 [root@test ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@test ~]# uname -r 2 ...

随机推荐

  1. Apache httpd.conf配置文件 3(虚拟主机)

    ### Section 3: Virtual Hosts 第三部分 虚拟主机 注意:在使用虚拟主机前,请先检查  http.conf 的 辅助配置文件httpd-vhosts.conf 是否注释 # ...

  2. Linux 目录解析

      FHS:Filesystem Hierarchy Standard(文件系统目录标准)的缩写,多数Linux版本采用这种文件组织形式,类似于Windows操作系统中c盘的文件目录,FHS采用树形结 ...

  3. win7下彻底卸载和重装mysql

    1 .目的:第一次安装完mysql后忘记了临时密码,通过各种途径都无法更改密码,因此不得不把mysql卸载了. 2 .建议:第一次安装mysql时会分配一个临时密码,如最后一行的se_:j<tq ...

  4. 大数四则运算之减法运算-----c语言版

    /* 分三种情况: 1.减数长度大于被减数 交换减数与被减数,输出负号,方便减 2.减数长度等于被减数(分三种情况) a.减数大于被减数,类似1情况1 b.减数等于被减数,两数相等,直接输出0,完成. ...

  5. Lua类的继承 参考实现

    参考url: https://blog.codingnow.com/cloud/LuaOO 最近在思考lua类的继承实现 ,参考了云风的类实现,感觉他的更像是接口写法.于是尝试用自己的方式重写了类实例 ...

  6. mongoose报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.

    mongoose报错:(node:15689) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes ...

  7. JMeter函数助手中Random函数详解

    1.__Random函数的生成 The minimum value allowed for a range of values:一个范围内允许的最小值 The maximum value allowe ...

  8. 关于OFFICE 文件在线编辑dsoframer

    下载dsoframer.ocx 系统为32位时:拷贝 dsoframer.ocx  到c:\windows\system32\dsoframer.ocx打开cmd命令行注册  regsvr32.exe ...

  9. Vue中的递归组件

    递归函数我们都再熟悉不过了,也就是函数自己调用自己.递归组件也是类似的,在组件的template内部使用组件自身.那递归组件有什么使用场景呢? 我们都知道树这个数据结构就是一种递归的结构,因此我们可以 ...

  10. 全国省市,4个直辖市geoCoord数据,用于echart gl 3d地图

    var geoCoordMap = { '北京': [116.4551, 40.2539], '东城区':[116.418757,39.917544], '西城区':[116.366794,39.91 ...