let's say i have
$flags=JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
how can i then remove JSON_UNESCAPED_SLASHES from $flags
?
let's say i have
$flags=JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
how can i then remove JSON_UNESCAPED_SLASHES from $flags
?
It's not "C method" it's just applying bitwise operators
$flags=JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
var_dump($flags & JSON_UNESCAPED_SLASHES); // flag should be set to 1
$flags &= ~JSON_UNESCAPED_SLASHES; // remove it
var_dump($flags & JSON_UNESCAPED_SLASHES); // flag should be set to 0
In case you can't reach flags directly, as their are added later in 3rd party code (my case):
<?php
function notMyFunction($flags)
{
$finalFlags = $flags | FLAG_I_DONT_WANT;
// ...
}
There is this trick:
<?php
notMyFunction(FLAG_I_DONT_WANT - 1);