I am writing a simple php code on my localhost. I want to see the content of a text file which is in the same directory as the page. I have tried many codes, but the only outputs i see are warnings or just couple of question marks, like:
when i use this path “./sameFolder/file.txt”;
I get, ??? in firefox browser
when I use this path “file.txt” I get Warning: file_get_contents(file.txt): failed to open stream: Permission denied
apparently the first one is the right format, but can’t figure out why i don’t see the content, and instead see question marks
<?php
//Get the content of file
$myFile = "./sameFolder/file.txt";
echo file_get_contents("$myFile");
?>
It was the permission. I thought i changed it to 777, which obviously didn’t. and that’s why i was confused and couldn’t figure out what was the problem.