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

 
  

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

thinkphp php7 Cannot use 'String' as class name as it is reserved_第1张图片

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 {

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


QQ交流群:136351212
查看原文: http://www.phpsong.com/2260.html

你可能感兴趣的:(thinkphp php7 Cannot use 'String' as class name as it is reserved)