An example library:
Code: Select all
class string
{
public static function str_replace_count(...) {...}
}Code: Select all
string::str_replace_count('search','replace',$subject,$count);Code: Select all
namespace string;
function str_replace_count(...) {...}
Code: Select all
if (!is_integer($count))
throw new exception('You must pass an integer you dummy');I'm just wondering am I doing something "wrong"?
Let's say that you pass a string into a built-in PHP function that takes only integers, it will inform you what you did wrong so shouldn't I do that too in my functions? And when something else goes wrong like fopen within the function then return false and log the error (and display it if the DEBUG mode for the script is enabled - in development stage).
Am I being utterly inane or does this make sense to you?
When I code in C# I use exceptions to exit from fatal problems and that makes me think if my approach here is rational.