Get the App
SLTechnology News&Howtos  ›  Development  › 

Thinkphp prompts Cannot use 'String' as class name as it is reserved what to do in the php7 environment

Shulou Source: shulou.com Published: 2022-06-03 20:24:02 10月06日 Update

This article mainly introduces how thinkphp prompts Cannot use 'String' as class name as it is reserved in the php7 environment. What is introduced in this article is very detailed and has a certain reference value. Interested friends must finish reading it!

I have a website that used to have no problem running thinkphp with php7, but recently found that there was an error when I opened the CAPTCHA.

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

After searching on google baidu, there is still no solution.

So I did it myself, and it seemed that I was the first person to share it.

Reason:

One class uses the string class name, and php7 sets String as the keyword

Solution:

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

Find:

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

Modified 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 CAPTCHA came out. I searched it. There was no reference anywhere else. The problem was solved.

The above is all the contents of the article "thinkphp prompts Cannot use 'String' as class name as it is reserved what to do in the php7 environment". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: What to do environment tips content files methods articles questions search verification value keywords keywords interests reasons places guys partners time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology Apple vpn Shulou Information