Jump to content

Grooper

New Members
  • Posts

    3
  • Joined

  • Last visited

Grooper's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. No doubt you are right, I was being hopeful that is would be something simple with PHP! Still, I thank everyone for their input!
  2. Thank's for the pointer, I'm not sure that's what's happening though: I made a simple test script: // Create a new file and put some text in it. $newFile = "new.txt"; @unlink($newFile); file_put_contents($newFile, "random text"); // Array of files to look at $files = array("existing file.txt", $newFile); foreach ($files as $thisFile) { echo "$thisFile:\n"; var_dump(is_readable($thisFile)); var_dump(file_get_contents($thisFile))."\n"; require($thisFile); echo "\n\n"; } Here I test a file I created in Windows, as well as a file created by the script itself, the output is below: existing file.txt: bool(false) string(36) "some random text I typed in earlier." some random text I typed in earlier. new.txt: bool(false) string(11) "random text" random text Interestingly file_get_contents() is now able to open the files, I must have been doing something wrong previously. But still, is_readable() returns FALSE, but PHP proceeds to be able to read the files anyway. The above test results are from the mapped drive on the NAS, running the same script locally gives: existing file.txt: bool(true) string(36) "some random text I typed in earlier." some random text I typed in earlier. new.txt: bool(true) string(11) "random text" random text here is_readable() returns TRUE. Again, this behaviour is curious to me, and is a problem because I was hoping to use a framework that calls is_readable() as a part of it's sanity check during opening files, and it means I can't have the convenience of having my dev files hosted on the NAS. I would be interested in anyone's input, presumably I am missing something trivial, but I am happy to run any tests suggested. For example, I thought it is likely to be a permissions issue, which would make it an issue with the NAS rather than with PHP, but the above script outputs make me wonder.
  3. Hi all, In short: My PHP CLI is unable to open files using file_get_contents() but will happily open them with include(). Long version: If I call is_readable() on any files it returns false, calling file_get_contents() on the same files also returns false, but I am able to include() the files. The files are ones I have created, but also applies to files created with PHP itself. The whole thing is hosted on a Synology NAS (for my convenience), I am running PHP CLI 8.x. If I run the same code files hosted on the local machine it runs just fine. Clearly there is something about the NAS causing some odd behaviour, but what could be causing it? How could PHP open files with include() but not file_get_contents()?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.