After execute this simple code:
$message = 'some text '.inet_pton('119.252.33.171');
throw new \Exception($message);
PHP returns Fatal Error
Fatal error</b>: in ...
This code is expected to return
Fatal error: Uncaught Exception: ..
But this is not happening. With this message, the error occurs in the class "Exception"!
Code example 1 from sandbox.onlinephpfunctions.com (comment and uncomment 2 lines of code 3-4 and 6-7)
Code example 2 from sandbox.onlinephpfunctions.com
This behavior is noticed when converting many other IPs. At the moment I solved the problem with the following line before "throw new":
$message = preg_replace( '/[^[:print:]\r\n]/', '_', $message);
How to properly escape characters in message for Exception or it is PHP bug?
My PHP version is 7.2
Fatal error. Did you catch the Exception?'some text '.inet_pton('119.252.33.171');itself causes an error in the Exception class. Run my example on your hosting and look at the result.inet_ptoncall. Are you sure that's the cause of the exception?<br /> <b>Fatal error</b>: in <b>...</b> on line <b>92</b><br />