how catch a warning by file_put_contents() ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I wrote stuff with file_put_contents() in a try{} catch{} and it worked.

Then I'd like to check what happens when some error occurs so I writeprotected the targetfile. Instead of getting my own message by the catch{} block I got a standard warning in the browser.

Can't I catch those warnings, too?
And why does this function rise a warning when it can't acomplish it's task?


Samplecode:
    try {
        $msg = date ("d.m.Y H:i:s") . 'This should be stored in the file.';
file_put_contents( '/tmp/exceptions.txt', $msg . "\n", FILE_APPEND);
    }
    catch ( Exception $e ) {
        $msg = "Exception " . $e->getCode() . " / " . $e->getMessage();
        echo "<p>$msg</p>";
    }

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux