Home > Backend Development > PHP Tutorial > 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

不言
Release: 2023-03-30 11:30:01
Original
2609 people have browsed it

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);
Copy after login

Change to:

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

Copy the file:

ThinkPHP\Library\Org\Util\String.class.php
Copy after login

Save as:

ThinkPHP\Library\Org\Util\Stringnew.class.php
Copy after login

Open Stringnew.class.php:

class String {
Copy after login

Modified to:

class Stringnew {
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template