“哥,我再也不跑了。”
心早已成了碎片,无法拼起。
藤枯了,花谢了,我也苍老了。颤颤巍巍的走在喧嚣的街道上,没人认识我,也许根本就没有人能看得清我的面孔。秋风尽惹寂寥,最后一次给我送来了清晰的过往。
“滚!你给我滚,滚得越远越好!”母亲愤怒到极点了,眼神中全没了我往日的乖巧,说完就抄起粗大的樟树棒开始打我。
我完全吓傻了,再也没跑,只是让那沉重沉重的棍棒一棍一棍的敲打着我的脊梁。
php框架里,有很多类文件。这些文件的引入,就需要借助自动加载函数来实现。
spl_autoload_register函数相当于__autoload的升级版,我们先来看看__autoload函数的用法。
我写了两个文件start.php、zhai.php
//start.php function __autoload($class){ require_once(strtolower($class).".php"); } $obj = new Zhai(); $obj->sayHello();
由于Zhai这个类没有声明过,当程序执行到new时,就会自动先触发__autoload函数,来引入相关文件:
//zhai.php class Zhai { public function sayHello(){ echo "hello
"; } }
在服务器里,通过php -m命令可以查看到gd这个模块,可是程序里用到imagecreatefromjpeg函数还是报错,如下所示:
这是因为gd扩展,没有安装jpeg这部分。
通过phpinfo查看,gd扩展部分的信息如下图所示:
可以看到gif、png、bmp,却就是看不到jpeg。
网上这个时候都会让你下载jpeg的源码包,然后再进行编译安装。
本人经过实践,在php8.0版本下,不用另外下载源码包。
进入php源码包的ext/gd目录,本人实践目录如下所示:
/opt/php-8.0.23/ext/gd
然后开始重新编译gd扩展,依次执行如下命令:
/usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config --enable-gd --with-jpeg --with-freetype make && make install
由于本人服务器有安装多版本php,所以执行phpize命令用的绝对路径,否则编译版本信息容易匹配不上。
今天在thinkphp6框架里连接mongodb,报authentication fail错误,如下图所示:
网上查到的解决方法如下,但是对我无效:
//文件位置:/vendor/topthink/think-orm/src/db/connector/Mongo.php if (empty($config['dsn'])) { $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}/" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : ''); $config['dsn'] .= ($config['database'] ? "/{$config['database']}" : ''); //添加此行代码 }
修改之前打印出来的连接地址格式如下(非真实地址,仅供参考格式):
今天在Centos7.6系统下编译安装php8.0,报如下错误:
ext/mbstring/.libs/mbstring.o: In function `_php_mb_match_regex': /root/php-7.4.26/ext/mbstring/mbstring.c:1027: undefined reference to `onig_new_match_param' /root/php-7.4.26/ext/mbstring/mbstring.c:1029: undefined reference to `onig_initialize_match_param' /root/php-7.4.26/ext/mbstring/mbstring.c:1031: undefined reference to `onig_set_match_stack_limit_size_of_match_param' /root/php-7.4.26/ext/mbstring/mbstring.c:1034: undefined reference to `onig_set_retry_limit_in_match_of_match_param' /root/php-7.4.26/ext/mbstring/mbstring.c:1037: undefined reference to `onig_search_with_param' /root/php-7.4.26/ext/mbstring/mbstring.c:1040: undefined reference to `onig_free_match_param' ext/mbstring/.libs/php_mbregex.o: In function `zif_mb_ereg_match': /root/php-7.4.26/ext/mbstring/php_mbregex.c:1401: undefined reference to `onig_new_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:1402: undefined reference to `onig_initialize_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:1410: undefined reference to `onig_match_with_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:1411: undefined reference to `onig_free_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:1407: undefined reference to `onig_set_retry_limit_in_match_of_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:1404: undefined reference to `onig_set_match_stack_limit_size_of_match_param' ext/mbstring/.libs/php_mbregex.o: In function `_php_mb_onig_search': /root/php-7.4.26/ext/mbstring/php_mbregex.c:873: undefined reference to `onig_new_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:875: undefined reference to `onig_initialize_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:877: undefined reference to `onig_set_match_stack_limit_size_of_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:880: undefined reference to `onig_set_retry_limit_in_match_of_match_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:883: undefined reference to `onig_search_with_param' /root/php-7.4.26/ext/mbstring/php_mbregex.c:884: undefined reference to `onig_free_match_param' collect2: ld returned 1 exit status make: *** [sapi/cli/php] 错误 1
在数学中,我们知道当a=b,b=c时,可以得出a=c的结论。
但是PHP中,等于分为==和===这两种。
针对==这一种,在a==b,b==c的前提下,是不能一定得出a=c的结论的。
示例:
示例输出结果是”I love 0“而不是”I love 1“,即a变量不等于(!=)c变量。
今天测试“审批流撤销”功能,突然遇到一个奇怪的问题:日志显示新增数据成功,db里却查不到。
代码如下:
try{
$service_document->retreat($workflow_type_id, $doc_manage_id);
$this->requestSuccessResponse();
}catch(\Exception $e){
$service_log = new LogService();
$service_log->createLog($doc_manage_id, LabelService::TEXT_LOG_CATEGORY_DOCUMENT, $e->getMessage());
$this->requestErrorResponse("retreat fail");
}
createLog是添加日志记录的方法。测试功能,提示了retreat fail,但是数据库日志表里却看不到数据。
新增日志的方法,打印出sql以及新增之后的主键ID,都是没问题的。
问题出在Service里retreat方法上。先上代码:
$res3 = $obj_model->table('tms_new_workflow_process')
->where(array('workflow_type_id' => $type, 'subject_id'=> $doc_manage_id))
->save($process_update);
if(false === $res3){
$obj_model->rollback();
throw new Exception("update workflow process fail!");
}
$obj_model->commit();
$("#list_language_file").html(htmlLanguageFile);
$('#mainTab').tabs('add',{
width:$("#mainTab").parent().width() - 180,
title: " Document Detail-" + dataCellClick.doc_name,
iconCls: null,
href: 'Document/documentDetail?doc_manage_id='+dataCellClick.doc_manage_id,
closable: true
});