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. VFP的13个SPT函数

    Visual FoxPro 中内置了13个以SQL开头的函数,我们把它们称为SPT函数.就是这13个函数完成了Visual FoxPro的所有的SQL Pass Though功能.从功能上看,我们可以 ...

  2. MongoDB oplog 详解

    oplog 简介 oplog 是local库下的一个固定集合,Secondary就是通过查看Primary的oplog这个集合来进行复制的.每个节点都有oplog,记录从主节点复制过来的信息,这样每个 ...

  3. ubuntu16.04 自建源

    来自于https://www.cnblogs.com/liangqihui/p/7150066.html APT本地源的搭建(可用于局域网apt-get源搭建或者本地源) 本文档介绍使用apt-mir ...

  4. expect知识梳理

    1 expect expect软件用于实现非交互式操作,实际应用中常用于批量部署,可以帮助运维人员管理成千上万台服务器. expect实现非交互式操作主要是在程序发出交互式询问时,按条件传递程序所需的 ...

  5. codewars--js--the highest and lowest number + JS 字符串和数组相关知识

    本文参考: http://blog.csdn.net/tyrionj/article/details/78653426 http://www.runoob.com/jsref/jsref-obj-st ...

  6. 基于SSM开发自行车在线租赁管理系统源码

    开发环境: Windows操作系统开发工具: Myeclipse+Jdk+Tomcat+MYSQL数据库注意:此项目分管理员与普通用户两种角色运行效果图 源码及原文链接:https://javadao ...

  7. html基本介绍,了解html与css,html语法和结构

    一般来说,制作自己第一个网页通常书写的文字是"hello world!你好,全世界",代码如下展示: <!DOCTYPE html> <html lang=&qu ...

  8. 如何利用border书写三角形,建议考虑正方形

    网页做三角形图片,你还在拿ps调整吗?out了,老铁,来和我一起脑海畅想一个正方形是由4个等腰直角三角形构成,然后我想保留上边的三角形,那下边.左边.右边的三角形就没了(设置背景色transparen ...

  9. Asciidoctor-pdf生成pdf文件

    本文使用asciidoc语法编写. = Asciidoctor-pdf生成pdf文件 Pinnsvin Pinnsvin@163.com v1.0 {docdate} :plantuml-server ...

  10. go笔记--几个例子理解context的作用

    目录 go笔记--几个例子理解context的作用 context interface 先看一个简单的例程 context的作用 contxt相关函数 go笔记--几个例子理解context的作用 经 ...