Home > other >  xampp php - link to directory not in root
xampp php - link to directory not in root

Time:02-17

I am running XAMPP on Win7 SP1 and I have encountered a problem.

I have a dir structure similar to this:

htdocs
_ head.php

  • runes
    _ algiz.php

From inside of algiz.php I want to include the files head.php since I have a couple of includes in there like my style sheets, etc. If I run a file in the root that includes the head.php I have no issues.

However, if I try to run the algiz.php I get an error when it tries to access head.php. I am using require "../head.php";

When I try this I get the following errors.

Warning: require(head.php): Failed to open stream: No such file or directory in E:\XAMPP\htdocs\runes\algiz.php on line 3

Fatal error: Uncaught Error: Failed opening required 'head.php' (include_path='E:\XAMPP\php\PEAR') in E:\XAMPP\htdocs\runes\algiz.php:3 Stack trace: #0 {main} thrown in E:\XAMPP\htdocs\runes\algiz.php on line 3

I even tried to visit the dir htdocs/runes from my browser and I saw algiz.php listed. Then I clicked on the algiz.php and got the same errors.

EDIT: I thought that it may not be clear, but the runes dir is a sub in the htdocs folder.....

So, any insight or suggestions are greatly appreciated. Jim

CodePudding user response:

Your warning only says require(head.php) not require(../head.php)

Are you sure you're actually using require "../head.php ?

Maybe you got some weird character in there? Try rewriting the line, just to be safe.

CodePudding user response:

I saw the require(head.php) also... Not sure why it is showing that.

Just for the hell of it, opened the file in M$ Office and set show nonprintable characters. Only thing that showed was the paragraph mark at the end of the line.

Deleted the file off of my server. But, reloaded the local file and retyped the line anyway, same issue.

Opened the file using my FTP and retyped the line using Notepad, same.

Opened my site locally using XAMPP, same issue.

There are two things driving me completely nuts. One is the error message. Two is not being able to figure this out...

EDIT: I don't think this should make a difference, but I am using PHP version 8.0.15

  • Related