摘要: PHP针对xml手册中列举了12个扩展,其中有几个不错的扩展:simpleXML, DOM, libxml. 前几天用到,简单介绍一下。如果解析一个已知结构的XML,最简答的莫过于simpleXML, 简单粗暴。下面给一个例子.function parseXml($xml) { # LIBXML_NOCDATA 选项用于解析 中的数据 $parser = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); if($parser !== false) { return array(... 阅读全文
posted @ 2013-07-17 18:59 代码会说话 阅读(376) 评论(0) 推荐(0) 编辑
摘要: 在编写php程序中,经常要更改环境变量,在这把一些常用的整理一下。set_time_limit(): 在执行脚本时,经常需要设定一些时间限制,以防脚本执行时间过长。Warning: Any time spent on activity that happens outside the execution of the script such as system calls usingsystem(), stream operations, database queries, etc. is not included when determining the maximum time that 阅读全文
posted @ 2013-07-17 18:04 代码会说话 阅读(288) 评论(0) 推荐(0) 编辑
摘要: PHP下载远程文件可以通过多种方式。如果下载链接直接对应于远程文件,使用fopen($url, 'rb');返回句柄读取即可。Warning: 注意设置fopen的timeout;注意判断句柄是否为空。 1 function download($src, $dst) 2 { 3 $timeout = 100; 4 $old = ini_set('default_socket_timeout', $timeout); 5 $srcH = fopen($src, "rb"); 6 ini_set('default_socket_timeo 阅读全文
posted @ 2013-07-17 11:36 代码会说话 阅读(323) 评论(0) 推荐(0) 编辑