diff options
-rw-r--r-- | include/call.h | 1 | ||||
-rw-r--r-- | zend/exception_handler.cpp | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/call.h b/include/call.h index 55e9ed6..9b1725a 100644 --- a/include/call.h +++ b/include/call.h @@ -48,6 +48,7 @@ extern PHPCPP_EXPORT Value require_once(const char *filename); inline PHPCPP_EXPORT Value require_once(const std::string &filename) { return require_once(filename.c_str()); } extern PHPCPP_EXPORT Value set_exception_handler(const std::function<Value(Parameters ¶ms)> &handler); extern PHPCPP_EXPORT Value set_error_handler(const std::function<Value(Parameters ¶ms)> &handler, Error error = Error::All); +extern PHPCPP_EXPORT Value error_reporting(Error error); extern PHPCPP_EXPORT const char *sapi_name(); /** diff --git a/zend/exception_handler.cpp b/zend/exception_handler.cpp index b864e78..aa925f9 100644 --- a/zend/exception_handler.cpp +++ b/zend/exception_handler.cpp @@ -72,6 +72,30 @@ Value set_error_handler(const std::function<Value(Parameters ¶ms)> &handler, } /** + * Modify the error reporting level, will return the old error reporting level. + */ +Value error_reporting(Error error) +{ + // store the old error reporting value + Value output(EG(error_reporting)); + + // create a small temporary buffer + char str[21]; + + // write the level into this buffer + int size = sprintf(str, "%d", (int) error); + + // if we failed for some reason we bail out + if (size < 0) return false; + + // alter the ini on the fly + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), str, size, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + + // return the output + return output; +} + +/** * End of namespace */ } |