4-08 2,836 views
阅读全文 0
<?php
header('Content-type:text/html;charset=utf-8');
$a = 1;
$b = 2;
try {
//结果为真,设置异常信息
if( $a < $b )
{
throw new Exception('a要大于b');
}
} catch (Exception $err)...
3-23 3,646 views
<?php
header('Content-type:text/html;charset=utf-8');
$a = 1;
$b = 2;
try {
//结果为真,设置异常信息
if( $a <...
背景:
准备使用laravel框架(http://laravel.com),但是阿里云服务器上的php版本为 5.5.3,laravel的系统要求是 php版本 > 5.3.7.
问题:
使用 yum update-check,结果 当前 centos上的源的php版本还是5.5.3,所以决定换个源;
步骤:
1、参考:http://w...
3-23 6,460 views
背景:
准备使用laravel框架(http://laravel.com),但是阿里云服务器上的php版本为 5.5.3,laravel的系统要求是 php版本 > 5.3.7.
问题:
使用 yu...
"读取文件到数组"
使用file函数
<?php
$file = file('1.html');
$alt = '';
print_r($file);
?>
"读取文件到字符串"
使用file_get_contents函数
<?php
$file = file('1.html');
print_r($file);
?>...
3-19 3,633 views
阅读全文 0
"如何获得一个月的天数"
使用strtotime、data函数及占位符t
<?php
$timestamp = strtotime('October');
//也可以这么写$timestamp = strtotime('2012-02');
$days = date('t',$timestamp);
echo $days; //31
?>
3-19 3,560 views
阅读全文 0
定义和用法
trim() 函数从字符串的两端删除空白字符和其他预定义字符。
语法
trim(string,charlist)
参数
描述
string
必需。规定要检查的字符串。
charlist
可选。规定要转换的字符串。如果省略该参数,则删除以下所有字符:
“\0” – NUL...
3-19 3,840 views
阅读全文 0
定义和用法
nl2br() 函数在字符串中的每个新行 (\n) 之前插入 HTML 换行符 (<br />)。
语法
nl2br(string)
参数
描述
string
必需。规定要检查的字符串。
例子
输出:
One line.
Another line.
HTML 代码:
One line.<br />
Another lin...
3-19 3,434 views
阅读全文 0
Ajax分割上传文件,无视php限制2M最大上传
<script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
$('#btn').click(function() {
sendf...
3-18 4,845 views
Ajax分割上传文件,无视php限制2M最大上传
<script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
<script...
定义和用法
stripslashes() 函数删除由 addslashes() 函数添加的反斜杠。
语法
stripslashes(string)
参数:string 。 描述:规定要检查的字符串。
例子
<!--?php echo stripslashes("Who\'s John Adams?"); ?-->
输出
Who's John Adams?
3-18 3,101 views
定义和用法
stripslashes() 函数删除由 addslashes() 函数添加的反斜杠。
语法
stripslashes(string)
参数:string 。 描述:规定要检查的字符串。
例子
<...