Solution for php include not working: 1. Use ftp to modify the permissions of the entire directory; 2. Modify the encoding; 3. Change "include("xxxx")" to matching case.
The operating environment of this article: linux5.9.8 system, PHP7.1 version, DELL G3 computer
What should I do if php include does not work?
Linux php file include fails, a very magical problem
1. HTML generation failed, permission problem
The day before yesterday, I used php to generate the template and developed it on windows. include file, read the cache and write the file, it went smoothly. After writing it at night, the HTML generation failed when uploaded to Linux. I found that neither the file nor the folder was generated. I searched online and said it was a permissions issue, so I used ftp to modify the permissions of the entire directory and right-clicked the file. folder, I saw that there is a CHMOD item in the menu. After selecting it, as shown below, all permissions are opened. After
, the files can be generated, but I encountered a weirder problem. It took more than 1 day;
2. Include file failed
There is no problem with include on Windows, but it fails on Linux, and there are a lot of permission issues. The final test method is as follows:
1. Create the simplest .php file, which only outputs simple text. Even the file name must be simple, and the output is included successfully! ! It can be seen that it is not a permissions issue.
2. I suspected that there was something wrong with the content of the file I included, so I gradually reduced the file I included, but the inclusion failed. Finally, I simply reduced it to just one line of simple output, but it still failed;
3. Oh, Suddenly an idea flashed, there was a file encoding problem! ! After checking, sure enough! ! Quickly change the encoding to utf-8, but the include still fails. During the period, I have been testing on local windows and it is successful;
4. Why, why does the file include test succeed on Linux, but the file I want to include fails? , these two files are simple outputs, and the file encoding is the same. Could it be that...my file is cursed? This file name...
5. Finally, finally, is it the case of the file name (crying tone)? After careful comparison, the case of the file name really does not match. Change include("xxxx") For matching case, it worked. . But I'm not happy at all;
6. Linux, this,,,, include must be case-sensitive, maybe it's just Alibaba Cloud. . .
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if php include doesn't work?. For more information, please follow other related articles on the PHP Chinese website!