SIMPLE_DATE
SIMPLE_DATE = "Y-m-d H:i:s"
Formats incoming records into a one-line string
This is especially useful for logging to files
__construct(string $format = null, string $dateFormat = null, boolean $allowInlineLineBreaks = false, boolean $ignoreEmptyContextAndExtra = false)
string | $format | The format of the message |
string | $dateFormat | The format of the timestamp: one supported by DateTime::format |
boolean | $allowInlineLineBreaks | Whether to allow inline line breaks in log entries |
boolean | $ignoreEmptyContextAndExtra |
detectAndCleanUtf8( $data)
Detect invalid UTF-8 string characters and convert to valid UTF-8.
Valid UTF-8 input will be left unmodified, but strings containing invalid UTF-8 codepoints will be reencoded as UTF-8 with an assumed original encoding of ISO-8859-15. This conversion may result in incorrect output if the actual encoding was not ISO-8859-15, but it will be clean UTF-8 output and will not rely on expensive and fragile detection algorithms.
Function converts the input in place in the passed variable so that it can be used as a callback for array_walk_recursive.
$data |
handleJsonError(integer $code, mixed $data) : string
Handle a json_encode failure.
If the failure is due to invalid string encoding, try to clean the input and encode again. If the second encoding attempt fails, the inital error is not encoding related or the input can't be cleaned then raise a descriptive exception.
integer | $code | return code of json_last_error function |
mixed | $data | data that was meant to be encoded |
if failure can't be corrected
JSON encoded data after error correction