首页 文章 精选 留言 我的

精选列表

搜索[php框架],共10000篇文章
优秀的个人博客,低调大师

你应该这个姿势学习PHP(4)

1、fopen() fwrite() fclose() fiel_put_contents 1)fopen($path,'xx') 打开一个文件xx = r 是以只读的方式打开并将指针指向头部xx = r+ 读写方式打开xx = w 写入方式,并清空文件内容,指针执行头部,不存在则创建xx = w+ 读写方式,后面同上xx = a 写入方式并将指针执行头部,但是写入会覆盖之前存在内容,如果不存在则创建xx = a+ 读写方式,其他同上2)fwrite($handle,content) 向文件中写入文字3)flcose($path) 关闭文件4)file_put_contents('file',content) 向文件中写入内容 应用场景:做文件的缓存以及做网站的日志记录等 2、fread() feof() fgets() fgetss() fgetc() file_get_contents() file() 1)fread($handle,$size) 从一个文件中获取指定字节大写的内容2)feof($handle) 判断指针是否已经到达尾部3)fgets() 从文件中读取一行4)fgetss() 读取一行并过来html4)fgetc() 从文件中读取一个字符5)file_get_contents() 从一个文件句柄里面获取内容6)file() 同上 应用场景:并发不是很高的情况下可以配置文件锁的机制做队列功能 for example: $handle = fopen('1.txt','r');while(!feof($handle)){ echo fgetc($handle); }fclose($handle); 3、file_exists() 1) file_exists() 检查文件或者目录是否存在 应用场景,我们做图片上传的时候,判断目录是否存在,如果不存在就创建 for example: $handle = 'uploads/test';if(!file_exists($handle)){ mkdir($handle,0777,true); } 4、is_dir() is_file() is_link() is_readable() is_writeable() is_writable() is_uploaded_file() is_executable() 1)is_dir() 是否是一个目录2)is_file() 是否是一个文件 应用场景:我们在循环遍历一个目录的时候,可以判断是否是目录,如果是将递归遍历 5、copy() move_uploaded_file() rename() 1)copy($one,$two)2)move_uploaded_file() 应用场景:上传图片,移动临时文件到指定的目录 3)rename() 6、filesize() filetype() 1)filesize() 获取文件的大小2)filetype() 获取文件的类型 7、pathinfo() 1)pathinfo() 返回路径的信息 8、dirname() basename() 1)dirname() 返回路径中的目录部分2)basename() 返回路径中的文件部分 9、fileatime() filemtime() filectime() touch() 1)fileatime() 获取文件的上次访问时间2)filemtime() 获取文件的修改时间3)filectime() 获取文件的修改时间4)touch() 设置文件的访问和修改时间 10、mkdir() unlink() rmdir() 1)mkdir($path,0777,true) 创建文件2)unlink($file) 删除文件3)rmdir() 删除目录 11、feof() fseek() rewind() ftell() 1)feof() 测试文件是否到了文件文件结束的位置2)fsweek() 在文件中指针中定位3)rewind() 倒回文件指针的位置4)ftell() 返回文件读写的位置

优秀的个人博客,低调大师

BMH子串查找算法(PHP实现)

代码 interface StringSearchable { public function search($substring, $buffer); } class BoyerMooreStringSearch implements StringSearchable { public $substring = null; public $buffer = ''; public $jumpTable = array(); protected $results = array(); public function __construct() { } public function __destruct() { } public function search($substring, $buffer) { $this->results = array(); $this->substring = $substring; $this->buffer = $buffer; $this->deriveJumpTable(); $substringLen = strlen($this->substring); $currentCharIndex = $substringLen - 1; $bufferLen = strlen($this->buffer); while ($currentCharIndex < $bufferLen) { for ($i = $substringLen - 1; $i >= 0; $i--) { if ($this->buffer[$currentCharIndex - $substringLen + $i + 1] == $this->substring[$i]) { if ($i == 0) { $this->results[] = $currentCharIndex - $substringLen; $currentCharIndex += $this->getJumpLength($this->buffer[$currentCharIndex]); } else { continue; } } else { $currentCharIndex += $this->getJumpLength($this->buffer[$currentCharIndex]); break; } } } return (sizeof($this->results) > 0); } protected function deriveJumpTable() { $maxJump = strlen($this->substring); for ($i = strlen($this->substring) - 2; $i >= 0; $i--) { if (!array_key_exists($this->substring[$i], $this->jumpTable)) { $this->jumpTable[$this->substring[$i]]] = $maxJump - $i -1; } } } public function getJumpTable() { return $this->jumpTable; } public function getResults() { return $this->results; } public function getResultsCount() { return sizeof($this->results); } public function getJumpLength($charIndex) { if (array_key_exists($charIndex, $this->jumpTable)) { return $this->jumpTable[$charIndex]; } else { return strlen($this->substring); } } } function Main() { $poem = <<<POEM you son of bitch god damn it hey,god love me POEM; $bm = new BoyerMooreStringSearch(); $bm->search('god', $poem); $count = $bm->getResultsCount; echo $count; } 复制代码 本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2010/04/21/1717668.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码