It’s been a while since I’ve touched PHP, and I’ve been working in C# for a while. I need to do some file reading/writing, but I’m not sure where to start. I’ve been spoiled by Visual Studio’s code-completion and real-time error checking, and it’s a bit difficult going over to such a weakly-typed language.
In PHP, what’s returned when reading a file, and what needs to be written when writing?
I need to work with the file in hex, but decimal would be fine too. Is there any way to read it in any way but a string?
There is a several ways to read and write files:
You can create a handler by
fopen()function.The other way is just
file_get_contents(), this function just returns content. Andfile_put_contents()just put any data to file.As example of the handler, here is a logging stuff:
Here you can read about and Filesystem managment functions