php 日期不全补0实例程序代码

 $time = '2010-1-11';
 
 //定义一个日间我相把把它变成2010-01-1
 
 $splitDate = explode("-",$time);
 
 //进行拆分以"-"分开
 
 $stime = mktime(0,0,0,$splitDate[1],$splitDate[2],$splitDate[0]);
 
 //再用mktime把它转换成时间载
 
 if( intval( $splitDate[1] )<10 && substr( $splitDate[1],0,1) !='0' )
 {
  $splitDate[1] = '0'.$splitDate[1];
 }
 //对月分取一个数字判断如果是01这种格式就不操作反之就加个0
 
 if( intval( $splitDate[2] )<10 && substr( $splitDate[2],0,1) !='0' )
 {
  $splitDate[2] = '0'.$splitDate[2];
 }
 //对日期作同样的作了,小于10就补0
 
 /*
  函数分析:
   explode 使用一个字符串分割另一个字符串 array explode ( string separator, string string [, int limit] )
   <a href=/phper/21/101d7c9a91356a428c8039c03dd4500b.htm>mktime</a>  函数返回一个日期的 Unix 时间戳。 mktime(hour,minute,second,month,day,year,is_dst)
   <a href=/phper/18/9351c693420d88336920eb2c12fca245.htm>intval</a> int intval ( mixed var [, int base])
通过使用特定的进制转换(默认是十进制),返回变量 var 的 integer 数值。

阅读全文

PHP命名空间规则解析及高级功能

日前发布的PHP 5.3中,最重要的一个新特性就是命名空间的加入。本文介绍了PHP命名空间的一些术语,其解析规则,以及一些高级功能的应用,希望能够帮助读者在项目中真正使用命名空间。

阅读全文

php cURL 抓取网页 POST数据及其他

使用PHP的cURL库可以简单和有效地去抓网页。你只需要运行一个脚本,然后分析一下你所抓取的网页,然后就可以以程序的方式得到你想要的数据了。无论是你想从从一个链接上取部分数据,或是取一个XML文件并把其导入数据库教程,那怕就是简单的获取网页内容,cURL 是一个功能强大的PHP库。本文主要讲述如果使用这个PHP库。

阅读全文

php 模拟用户获取远程文件内容

1,ini_get : Returns the value of the configuration option as a string on success, or an empty string on failure(读取 php教程.ini 配置文件中的值) 

2,; Whether to allow the treatment of URLs (like http:// or ftp://) as files. 

阅读全文