I think it should be `$attribute ? ENT_COMPAT : 0;`

1. This adds some space separation around the ternary conditions to make it more readable.
2. I think removing the `!` will be a little fast as there is one less operation.
3. In attribute mode the `"` should be escaped but not the `'`. See http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#escapingString