Home  >  Article  >  Backend Development  >  The solution to the problem that thinkphp prompts Cannot use 'String' as class name as it is reserved in php7 environment

The solution to the problem that thinkphp prompts Cannot use 'String' as class name as it is reserved in php7 environment

不言
不言Original
2018-06-07 10:45:422572browse

This article mainly introduces the solution to thinkphp prompting Cannot use 'String' as class name as it is reserved in the php7 environment. It involves thinkPHP's related underlying code modification skills for php7 keyword determination. Friends in need can refer to it. Next

The example in this article describes the solution to the problem that thinkphp prompts Cannot use 'String' as class name as it is reserved in the php7 environment. Share it with everyone for your reference, the details are as follows:

I have a website that used php7 to run thinkphp without any problems, but recently I found an error when turning on the verification code

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

After searching on google baidu, there is still no solution

So I solved it myself. It seems that I am the first person to share it

Reason:

There is a class that uses the string class name, and php7 sets String as Keyword

Solution:

File ThinkPHP\Library\Org\Util\Image.class.php

Found:

import('ORG.Util.String');
$code = String::rand_string($length, 4);

Change to:

import('ORG.Util.Stringnew');
$code = Stringnew::rand_string($length, 4);

Copy the file:

ThinkPHP\Library\Org\Util\String.class.php

Save as:

ThinkPHP\Library\Org\Util\Stringnew.class.php

Open Stringnew.class.php:

class String {

Modified to:

class Stringnew {

Put it up and the verification code comes out. I searched and found no other references. This problem is solved

The above is the detailed content of The solution to the problem that thinkphp prompts Cannot use 'String' as class name as it is reserved in php7 environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php optimization skillsNext article:php optimization skills