一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

解决thinkphp php7 Cannot use ‘String’ as class name as it is reserved

时间:2016-03-25 编辑:简简单单 来源:一聚教程网

我有一网站之前用php7运行thinkphp没有什么问题,但是最近发现开启验证码的时候发现有错误

Cannot use 'String' as class name as it is reserved

 

在google baidu搜索了一下还是没有解决方法
于是自己动手解决,看来我是第一个分享出来的人

原因:

有一个类用了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 {

放上去验证码出来了,我搜索了一下没有其他地方引用,这个问题解决了

 

原文链接地址:http://www.phpsong.com/2260.html

热门栏目