无法在同一文件夹中找到可用的文件

I'm trying to read the content of config.json file which is available in the same folder of the file that read it, this file is called settings.php, I actually have this line of code in settings.php:

$jsonData = file('config.json');

the problem's that I get:

Warning: file(config.json): failed to open stream: No such file or directory

this is weird because as you can see from the image:

enter image description here

I'm trying this app on localhost with mamp

This is most likely because your settings.php is included by a index.php that's a directory higher.

Php file opening will always assume from the "parent" php file where execution started as base directory and not of the included files.

Try using __DIR__

$jsonData = file(__DIR__.'/config.json');

__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(FILE). This directory name does not have a trailing slash unless it is the root directory.