Include dos work but file_get_contents does not with the same path (in wordpress)

I’m trying to read a JSON file with:

$path = ('CalendarFiles/gegevens.json');
$string = file_get_contents($path);

But I get the warning:

Warning: file_get_contents(CalendarFiles/gegevens.json): failed to open stream: No such file or directory in...

When i do an include with the same path I don’t get that warning it just “echo’s” the file, so the path does exist.

I tried to use urlencode() but stil the include is working and the file_get_contents is not.

I do this in a template of a WordPress site (I copied “page.php” and changed it), maybe it has something to do with WordPress? I’m very new to WordPress…

I hope you can help me, thanks in advance!

Read more here: Include dos work but file_get_contents does not with the same path (in wordpress)

Leave a Reply

Your email address will not be published. Required fields are marked *