这是因为用Redis接管了session状态储存,但是Redis又连接不正常导致的在服务器上查看Redis运行状态一切正常,set、get也没有问题,最后琢磨了半天才发现是PHPRedis扩展没有安装,所有PHP连接不上Redis,把扩展安装完后即可解决该问题 安装PHPRedis扩展 原文:https://www.cnblogs.com/shengxihui/p/10802195.html
1.问题 今天重新安装了ubuntu,PHP,MySQL,Apache,到测试CMS项目时发生一个错误: Fatal error: Uncaught Error: Call to undefined function simplexml_load_file() 2.解决: 2.1 安装php-xml:sudo apt-get install php-xml 2.2重启apache服务:sudo service apache2 restart 原文:http://www.cnblogs.com/wghao/p/6390168.html
本文实例讲述了php通过function_exists检测函数是否存在的方法。分享给大家供大家参考。具体分析如下:php中可以通过function_exists()函数检测另外一个函数是否存在,可以把函数名作为一个字符串传入function_exists,判断该还是是否存在
function highlight( $txt ) {return "<sub>$txt</sub>";
}
function textWrap( $tag, $txt, $func="" ) {if (function_exists( $func ) )$txt = $func($txt);return "<$tag>$txt</$tag>\n";
...
内容均以php5.6.14为例. 从一个封装 uniqid 的例子来讲。/* {{{ wrapper of uniqid */
PHP_FUNCTION(fox)
{ // #1.zval *prefix, *more = NULL;zval function, *params[2] = {0};// #2.if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &prefix, &more) == FAILURE ) {RETURN_FALSE;}params[0] = prefix;if (more) {params[1] = more;}// #3.ZVAL_STRING(&function, "uniqid", 0);// #4.if ( call_user_function(...
第一次在Mac下使用ThinkPHP,用到验证码功能时报如题的错误: Call to undefined function Think\imagettftext()然后检查自己的GD库,发现安装上了的。在网上找到解决方案:curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5参考资料来源:http://blog.csdn.net/ayonel613/article/details/51136070 原文:http://www.cnblogs.com/b-ruce/p/5858508.html
参数默认值function drink($kind =‘tea‘){echo ‘would you please a cup‘.$kind.‘<br>‘;}drink();drink(‘coffee‘);**********************************************可变长参数列表function tour(...$cities){ foreach($cities as $n) echo $n.‘<br>‘;}tour(‘beijing‘,‘shanghai‘,‘shenzhen‘);function sumOfInts(int ...$ints){return array_sum($ints);}var_dump(sumOfInts(1,‘4‘,4.8));结果:int(9);**********...
<?php
// 一、不要长时间链接
function get_ssl_avatar($avatar) {//$avatar = preg_replace('/.*/avatar/(.*)?s=([d]+)&.*/','<img class="avatar avatar-$2" src="https://secure.gravatar.com/avatar/$1?s=$2" alt="" width="$2" height="$2" />',$avatar);return $avatar;
};
add_filter('get_avatar', 'get_ssl_avatar');
// 二、缩略图添加
if ( function_exists( 'add_theme_support' ) ) add_theme_support( 'post-thumb...
此文转载自:https://blog.csdn.net/weixin_43932088/article/details/85983436DJBX33A又叫Times33哈希算法的实现与分析 算法:对字符串的每个字符,迭代的乘以33,目的把字符串转换成整数公式: hash(i) = hash(i-1)*33 + str[i] ; 乘于33是为了减少碰撞重复,简单点理解就是1+2和2+1是一样的,那1*33+2和2*33+1就不一样了。 为什么要用33,因为33是一个素数,能更好的散列,PHP内置的Hash函数用的素数是5381 OK,那我们用p...
/*更新商品的某个字段*/
function update_goods($goods_id, $field, $value)
{if ($goods_id){/* 清除缓存 */clear_cache_files();$sql = "UPDATE " . $GLOBALS[‘ecs‘]->table(‘goods‘) ." SET $field = ‘$value‘ , last_update = ‘". gmtime() ."‘ " ."WHERE goods_id " . db_create_in($goods_id);return $GLOBALS[‘db‘]->query($sql);}else{returnfalse;}
}
function message($msg, $url = NULL, $type = ‘succeed‘...
冷门的function:mb_substr()mb_strimwidth — 获取按指定宽度截断的字符串 常用function()原文:http://www.cnblogs.com/zhongyuan/p/4368481.html
自定义函数function.yangA.php页面 采用插件形式调用<?php
/*
* 文件名
* function.函数名.php function.yangA.php
* 声明的函数名规则
* smarty_function_函数名() smarty_function_yangA
* 参数
* 1.数组 array
* 2.smarty
* 模板使用
* <{yangA content="I am Mr.Yang" color="red" size="7" line="6"}>
*
*/
function smarty_function_yangA($args, $smarty){
$str = ‘‘;
...
在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会提示Call to undefined function imagecreate()错误。例,我在测试一个简单生成图形时实例Example #1 新建一个新的 GD 图像流并输出图像 代码如下复制代码<?php header("Content-type: image/png"); $im = @imagecreate(100, 50) or di...
register_shutdown_function函数的作用是注册一个函数,当php脚本执行完成,或者代码中调用了exit ,die这样的代码之后,执行预先注册好的函数.这样我们就可以在该函数中记录php调用执行的情况了.简单写了下,看起来应该可以用了<?phpfunction bdebug(){
$file="bdebug_log.txt";if($_REQUEST){foreach($_REQUEST as $k=>$v){
$request.=$k." = ".$v."\r\n";
}
}foreach($_SERVER as $k=>$v){
$server.=$k." = ".$v."\r\n";
}
$content=...
/*判断专传输数据是否为数字 用正则表达式判断输入的数字是否合法 调用:checknum(参数1,参数2) */ 代码如下:function checknum($id,$say) { $inid=$id; if(!ereg("^(-{0,1}|\+{0,1})[0-9]+(\.{0,1}[0-9]+)$",$inid)) { echo $say.",入口:"."<font color=red>".$inid."</font>"; exit; } } 调用 代码如下:<?php $tid="111fff"; checknum(...
php升级为5.3后,程序会报 Function split() is deprecated 的错误。这是因为种种原因(主要是关于正则的原因,具体见后),split这个函数在新版本不支持了。在php中,再使用deprecated的函数会报错,必须改掉。(java里deprecated的函数只是给警告,还可以继续用)改为什么呢? 看第一个参数,如果第一个参数不是正则表达式,split改为 explode;如果是正则表达式,split改为preg_split。explode会比以前快很多,因为以前要考虑正...