PHP常用
2015-03-18 19:33
92 查看
php.ini文件配置
时间配置PRC中国
date.timezone = PRC
文件上传
file_uploads = On //支持http上传
upload_tmp_dir = //临时文件保存路径
upload_max_filesize = 2M //上传的大小限制
post_max_size = 10M //post提交的大小限制
max_file_uploads = 20 //允许一次上传的最大文件数
XDEBUG设置,函数嵌套循环次数:
报错内容:Fatal error: Maximum function nesting level of '100' reached, aborting!
解决办法
查找xdebug 找到zend_extension = “D:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9-x86_64.dll” 这句在前面加;注视掉,在后面加上
xdebug.max_nesting_level = 500
乱码处理
防止乱码 先把utf-8转换成gb2312,copy完成后再转回utf-8
$newFile = iconv("utf-8","gb2312", $newFile);
输出字体颜色
echo '<span style="color:#F00" >字体为红色</span>';
格式化日期为时间戳
strtotime('2013-03-18')
$startTime='2013-03-18';
$endTime='2013-03-20'
$days=ceil((strtotime($endTime)-strtotime($startTime))/86400)+1 //求相差几天 60s*60min*24H
$shorStartTime=str_replace('-', '.', substr($startTime, 5)); //展示方式为03.18
php字符串处理
时间配置PRC中国
date.timezone = PRC
文件上传
file_uploads = On //支持http上传
upload_tmp_dir = //临时文件保存路径
upload_max_filesize = 2M //上传的大小限制
post_max_size = 10M //post提交的大小限制
max_file_uploads = 20 //允许一次上传的最大文件数
XDEBUG设置,函数嵌套循环次数:
报错内容:Fatal error: Maximum function nesting level of '100' reached, aborting!
解决办法
查找xdebug 找到zend_extension = “D:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9-x86_64.dll” 这句在前面加;注视掉,在后面加上
xdebug.max_nesting_level = 500
乱码处理
防止乱码 先把utf-8转换成gb2312,copy完成后再转回utf-8
$newFile = iconv("utf-8","gb2312", $newFile);
输出字体颜色
echo '<span style="color:#F00" >字体为红色</span>';
格式化日期为时间戳
strtotime('2013-03-18')
$startTime='2013-03-18';
$endTime='2013-03-20'
$days=ceil((strtotime($endTime)-strtotime($startTime))/86400)+1 //求相差几天 60s*60min*24H
$shorStartTime=str_replace('-', '.', substr($startTime, 5)); //展示方式为03.18
<?php //PHP计算两个时间差的方法 $startdate="2010-12-11 11:40:00"; $enddate="2012-12-12 11:45:09"; $date=floor((strtotime($enddate)-strtotime($startdate))/86400); $hour=floor((strtotime($enddate)-strtotime($startdate))%86400/3600); $minute=floor((strtotime($enddate)-strtotime($startdate))%86400/60); $second=floor((strtotime($enddate)-strtotime($startdate))%86400%60); echo $date."天<br>"; echo $hour."小时<br>"; echo $minute."分钟<br>"; echo $second."秒<br>"; ?>
<?php /** * 时间差计算 * * @param Timestamp $time * @return String Time Elapsed * @author Shelley Shyan * @copyright http://phparch.cn (Professional PHP Architecture) */ function time2Units ($time) { $year = floor($time / 60 / 60 / 24 / 365); $time -= $year * 60 * 60 * 24 * 365; $month = floor($time / 60 / 60 / 24 / 30); $time -= $month * 60 * 60 * 24 * 30; $week = floor($time / 60 / 60 / 24 / 7); $time -= $week * 60 * 60 * 24 * 7; $day = floor($time / 60 / 60 / 24); $time -= $day * 60 * 60 * 24; $hour = floor($time / 60 / 60); $time -= $hour * 60 * 60; $minute = floor($time / 60); $time -= $minute * 60; $second = $time; $elapse = ''; $unitArr = array('年' =>'year', '个月'=>'month', '周'=>'week', '天'=>'day', '小时'=>'hour', '分钟'=>'minute', '秒'=>'second' ); foreach ( $unitArr as $cn => $u ) { if ( $$u > 0 ) { $elapse = $$u . $cn; break; } } return $elapse; } $past = 2052345678; // Some timestamp in the past $now = time(); // Current timestamp $diff = $now - $past; echo '发表于' . time2Units($diff) . '前'; ?>
php字符串处理
substr_count($str,'|'); //计算某个字符在字符串中出现的次数 explode('|', $str, 2); //把一个字符以某个字符分割成几段
举例:7/3 整数部分:intval(floor(7/3)) 余数部分:7%3
相关文章推荐
- 基于php常用函数总结(数组,字符串,时间,文件操作)
- PHP常用的代码
- php中常用编辑器推荐
- PHP配置文件中最常用四个ini函数
- PHP一些常用的正则表达式
- PHP配置文件中最常用四个ini函数
- php中常用编辑器推荐
- php简单封装了一些常用JS操作
- PHP的常用函数
- 吐水奉献 ——PHP常用函数
- PHP中常用的Excel文件访问类及修改
- PHP_常用正则表达式
- php常用函数
- php开发wap常用技巧
- php中获得常用环境变量
- php中session常用函数
- php_mysql常用指令备忘
- PHP编程常用技巧
- PHP 中英文混合排版中处理字符串常用的函数
- PHP 中英文混合排版中处理字符串常用的函数