例
print_r(getimagesize('http://www.phprm.com/logo.jpg'));
输出的结果为:
Array
(
[0] => 550
[1] => 190
[2] => 3
[3] => width="550" height="190"
[bits] => 8
[mime] => image/png
)
例
print_r(getimagesize('http://www.phprm.com/logo.jpg'));
输出的结果为:
Array
(
[0] => 550
[1] => 190
[2] => 3
[3] => width="550" height="190"
[bits] => 8
[mime] => image/png
)
常量检测使用defined,定义常量则是define。注意待检测的常量需要使用引号(单双均可),如:
if (defined('CONST_NAME')) {
//do something
}
CJuiAutoComplete 在用户输入时可以根据用户输入的前几个字符自动提示用户可以输入的文字。它封装了 JUI autocomplete插件。
基本用法如下:
方法一:
<?php
http://pic2.phprm.com/2013/08/23/$url.jpg = “http://www.phprm.com”;
$fileExists = @file_get_contents($url, null, null, -1, 1) ? true : false;
echo $fileExists; //返回1,就说明文件存在。
?>
//计算年龄
根据年份计算生肖
例1
直接把日期转换
取得Response Headers,之后慢慢分析就行了。
给出具体实现方法:
date()函数
这个函数就比较熟悉了
计算数组平均值 二维数组平均值计算 分组计算平均值
$array = array(
array('class' => 'a', 'value' => 3),
array('class' => 'a', 'value' => 4),
array('class' => 'b', 'value' => 5),
array('class' => 'b', 'value' => 6)
)
php中就是在header一层判断是否是ajax请求,对应的根据$_SERVER['HTTP_X_REQUESTED_WITH']判断。
/**
* 当前请求是否ajax请求
*
* @access public
* @return bool
*/
function isAjax()
{
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'XMLHttpRequest';
}
正则替换掉网页中所有超链接
<?php
$content = file_get_contents('test.html');
$url = 'http://www.phprm.com'; //要换成的新网址
$preg = '/[s]href=("|')[S]*("|')/i';
$replace = ' href="' . $url . '"';
$content = preg_replace($preg, $replace, $content); //正则替换
create_log('newhtml', $content); //生成新文件
?>
php写文件的方法
实例一