Can I change the default settings for json_encode

I can't find anything in the PHP documentation, so maybe this is not possible without wrapping json_encode in a proprietary function.

But I was wondering, can I set the default parameters for json_encode function in php.ini or somewhere else?

The goal is to always have JSON_HEX_APOS and JSON_NUMERIC_CHECK, i.e.:

json_encode($object) will be equal json_encode($object, JSON_HEX_APOS | JSON_NUMERIC_CHECK)

+3
source share
2 answers

In addition to editing the source codes, there are no functions, although the function will be easy to create (as you said)

function j_code($object){
return json_encode($object, JSON_HEX_APOS | JSON_NUMERIC_CHECK);
}
+2
source

, , . , - ( ), , .

-2

All Articles