ignace Posted December 25, 2009 Share Posted December 25, 2009 Hi, I was wondering if it would be possible to use PHP's default error messages? I think this would be quit cool especially when it comes to type checking. Is this possible? And what do you think of such concept? Quote Link to comment https://forums.phpfreaks.com/topic/186348-default-error-messages-in-php/ Share on other sites More sharing options...
rajivgonsalves Posted December 25, 2009 Share Posted December 25, 2009 I am not sure what you mean by use php default error messages, please elaborate, if you want to show your own you can try http://php.net/manual/en/function.set-error-handler.php Quote Link to comment https://forums.phpfreaks.com/topic/186348-default-error-messages-in-php/#findComment-984053 Share on other sites More sharing options...
Daniel0 Posted December 25, 2009 Share Posted December 25, 2009 You can use trigger_error to raise E_USER_* errors. Aside from that, you cannot use PHP's error handling system. Quote Link to comment https://forums.phpfreaks.com/topic/186348-default-error-messages-in-php/#findComment-984055 Share on other sites More sharing options...
ignace Posted December 25, 2009 Author Share Posted December 25, 2009 @rajiv I think Daniel already partially answered my question but what I actually wanted is that when I define a user function and the user gives a wrong format (array instead of string) then it would report that error instead of me writing: __FUNCTION__ expects parameter two to be string, gettype($variable) given. It's possible I think when using the SPL extension: function functionName(SplString $param1, SplString $param2) Quote Link to comment https://forums.phpfreaks.com/topic/186348-default-error-messages-in-php/#findComment-984071 Share on other sites More sharing options...
Daniel0 Posted December 25, 2009 Share Posted December 25, 2009 You can type hint non-scalar parameter types. It'll result in a run-time fatal error if a non-matching type is given. You could write an RFC at http://wiki.php.net (and send it to the internals list) to have what I believe Java calls automatic boxing and unboxing. This would allow you to pass e.g. primitives like ints to an SplInt without having to do new SplInt(42). Quote Link to comment https://forums.phpfreaks.com/topic/186348-default-error-messages-in-php/#findComment-984073 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.