当前位置:首页 > PHP教程 > PHP常见问题

thinkphp在php7环境下提示Cannot use ‘String’ as class name as it is reserved的解决方法

本文实例讲述了thinkphp在php7环境下提示cannot use ‘string' as class name as it is reserved的解决方法。分享给大家供大家参考,具体如下:

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

cannot use 'string' as class name as it is reserved

在google baidu搜索了一下还是没有解决方法

于是自己动手解决,看来我是第一个分享出来的人

原因:

有一个类用了string类名,php7把string定为关键字

解决方法:

文件thinkphplibraryorgutilimage.class.php

找到:

import('org.util.string'); $code = string::rand_string($length, 4);

修改成:

import('org.util.stringnew'); $code = stringnew::rand_string($length, 4);

复制文件:

thinkphplibraryorgutilstring.class.php

保存成:

thinkphplibraryorgutilstringnew.class.php

打开stringnew.class.php:

class string {

修改成:

class stringnew {

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


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!