Handling Reading/Writing Files in PHP? -
Handling Reading/Writing Files in PHP? -
it's been while since i've touched php, , i've been working in c# while. need file reading/writing, i'm not sure start. i've been spoiled visual studio's code-completion , real-time error checking, , it's bit hard going on such weakly-typed language.
in php, what's returned when reading file, , needs written when writing?
i need work file in hex, decimal fine too. there way read in way string?
there several ways read , write files:
you can create handler fopen()
function.
the other way file_get_contents()
, function returns content. , file_put_contents()
set info file.
as illustration of handler, here logging stuff:
if (!is_writable($this->file) && $name !== self::core_log) { self::getinstance(self::core_log)->log(sprintf('couldn\'t write file %s. please, check file credentials.', $name)); } else { $this->handler = fopen($this->file, 'a+'); self::$instances[$name] = &$this; } ... if ($this->handler) fwrite($this->handler, '[' . date('r') . '] : ' . $l . "\n"); ... if ($this->handler) fclose($this->handler);
here can read , filesystem managment functions
php file
Comments
Post a Comment