PHP Require not including PHP files but e.g. as TXT does

Problems with the Linux version of XAMPP, questions, comments, and anything related.

PHP Require not including PHP files but e.g. as TXT does

Postby Corsari » 02. June 2021 11:11

Hello to all of you

have this issue that is making me crazy , quite difficult to understand problem

I have a micro PHP app that has index.php ad a couple of others files *.php that are included in the index.php developed with xampp

let's call the two to be included files include1.php and include2.php

Well, if I try to include include1.php and include2.php, they are NOT included and you get the PHP exception files not present in such path

But, listen listen, if I rename the two files include1.txt and include2.txt THEY ARE INCLUDED!!!

So thank you if you save me from this headache

Please note , the system is basically linux, but the linux of a Synology (updated) NAS with the webstation enabled and all the rest ... and since on the same NAS, I have installed PHPMyAdmin and it does work ...

the Synology webstation setup is running an Apache 2.4 with php 7.4

Thank you for ideas , hints and tips

Robert
Corsari
 
Posts: 15
Joined: 13. January 2015 07:24
Operating System: Windows Vista

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Nobbie » 02. June 2021 12:02

Please show us the full original error message, the full index.php (please dont change anything!) and a screenshot of a directory listing.

P.S.: How did you create include1.php? With Notepad, very often files are named include1.php.txt instead and Windows Explorer hides(!) the .txt extension. Therefore the files seem to be "include1.php", but are not and therefore are not found.
And do you mount the NAS to your linux file system? Maybe there is a problem with file rights as well.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Corsari » 02. June 2021 12:06

Hello thank you

I'll do it

cannot right now

But the thing is well explained above

In the same directory, the same index.php file I just change the include from include1.php to include1.txt and I then rename include1.php file to include1.txt

I refresh the browser and all the include1.txt content is printed, so include mechanism and DOCUMENT_ROOT variable are correctly working

while if browse with include1.php on the browser it shows the path and tells that index1.php is not present

all the three files do sits in the same directory

brb :-) I developed some years now, currently I do use Visual Studio Code, the app on xampp windows works like a charm
Last edited by Corsari on 02. June 2021 12:10, edited 1 time in total.
Corsari
 
Posts: 15
Joined: 13. January 2015 07:24
Operating System: Windows Vista

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Nobbie » 02. June 2021 12:09

We still dont know how your NAS is mounted to your PC? Where is Xampp installed? What is the DocumentRoot etc.? Running Apache from a NAS is always somewhat "tricky", as you have to give appropriate rights to appropriate users. There may also be a problem with uppercase/lowercase letters.
Last edited by Nobbie on 02. June 2021 12:12, edited 1 time in total.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Corsari » 02. June 2021 12:12

I'm just asking an hint

the NAS is Synology and you don't install .rpm or .deb files

you just "enable" packages

Just asking if such kind of behavior may be a setting of Apache or of PHP or if it is better to investigate something else

e.g. something to insert in .htaccess or (this is possible to be done) something to be edited in php.ini or in apache conf

thank you
Corsari
 
Posts: 15
Joined: 13. January 2015 07:24
Operating System: Windows Vista

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Nobbie » 02. June 2021 12:13

So this is not a Xampp installation. This forum is for Xampp Linux installations, we cannot support Synology NAS. Ask Synology if there is any restriction.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Corsari » 02. June 2021 12:16

Sure, just asking

if somebody knows

if some setting may do this kind of behavior either in apache or php
Corsari
 
Posts: 15
Joined: 13. January 2015 07:24
Operating System: Windows Vista

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Corsari » 02. June 2021 12:17

e.g. have you ev er heard about ONLY php files to NOT being included while others files type are correctly included?
Corsari
 
Posts: 15
Joined: 13. January 2015 07:24
Operating System: Windows Vista

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Nobbie » 02. June 2021 12:22

Similar, the Provider 1&1 for example does NOT allow *.inc files for include.

What happens, if you try to open the include1.php directly (instead of including it), for example via http://localhost/include1.php (or whatever URL you need for your NAS). Does Apache find it? Actually, you should ask Synology about that. I have no idea how the default configuration of their NAS is working. I personally have a QNAP NAS and it works fine.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: PHP Require not including PHP files but e.g. as TXT does

Postby Corsari » 02. June 2021 13:12

Forgot
Tried that too
Inserted and echo statement
It works
That is why I have asked here
Corsari
 
Posts: 15
Joined: 13. January 2015 07:24
Operating System: Windows Vista


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 29 guests