Re:New to PHP 5.4: Traits
by simast on Sunday November 21, 2010 @09:40AM
(#1927116)
I assume you are talking about fopen-type of functions that are nothing more but wrappers around C standard library functionality.
Use SplFileObject (part of SPL that is part of PHP core) for object-oriented way to manipulate files. On a failure (like your permission issue) it throws Exceptions and if not handled this will result in a "hard" error with a backtrace log.
Re:New to PHP 5.4: Traits
by cheald on Sunday November 21, 2010 @10:43AM
(#1927208)
Awesome, thank you. I'm a bit rusty on best practices since I've shifted my focus away from php, but it's nice to know that options to make it behave a bit more high level exist.
Use SplFileObject (part of SPL that is part of PHP core) for object-oriented way to manipulate files. On a failure (like your permission issue) it throws Exceptions and if not handled this will result in a "hard" error with a backtrace log.