1、 php7.1.10 把 mcrypt_generic 方法设为 即将遗弃的方法,php7.2将彻底遗弃不再使用,建议使用openssl_encrypt代替。
2、 PHP7 不再支持与类名相同的构造方法,构造方法统一使用 __construct(), 比如下面的写法 PHP7 就会报错误。
3、错误:
原因:
有一个类用了string类名,php7把String定为关键字
解决方法:
文件ThinkPHP\Library\Org\Util\Image.class.php
找到
import('ORG.Util.String');
$code = String::rand_string($length, 4);
修改成
import('ORG.Util.Stringnew');
$code = StringNew::rand_string($length, 4);
复制文件
ThinkPHP\Library\Org\Util\String.class.php
保存成
ThinkPHP\Library\Org\Util\StringNew.class.php
打开StringNew.class.php
class String {
修改成
class StringNew {
4、如果定义的方法没有给默认值,这时如果不传值,则报错:
5、 初始化变量时,如果给变量设为字符串,但是后面要转换为数组时,则报错:
6、php7中,preg_replace()不再支持"\e" (PREG_REPLACE_EVAL),需要使用preg_replace_callback()来代替。
$content = preg_replace("/{#(.+?)}/eis", '$lang[\'\\1\']',$content) ;
这是原来的代码,在php7里不能被正确执行。
$content = preg_replace_callback("/{#(.+?)}/is",function($r)use($lang){ return $lang[$r[1]]; }, $content);
7、// $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //接受post数据,PHP7废弃的全局变量
if(!$postStr){
$postStr = file_get_contents('php://input');
}