括号中的负值格式

normally php will output negative integer with this format -1234, how to it show in parentheses format (1234)

example:

$foo = 10 - 20;
// output: $foo = -10
// expected output $foo = (10)

I don't think there is a way to make PHP do this automatically.

echo ($foo < 0 ? "(".abs($foo).")" : $foo);

is the shortest solution that comes to mind.

In my opinion the easiest way is creating your own print function, out of the box with php this isn't possible.

function print_val($int){
    return ($int < 0) sprintf('(%d)', abs($int)) : $int;
}