You are in the middle of adding stuff to a string in the line starting with $data.
Two solutions:
1) Stop adding stuff, start your if, add more stuff inside, stop if, then add the rest in a new statement.
$data .= 'h'.$i.'{';
if ( !empty ($size) ) {.
$data .= 'font-size: ' .$size. ';'.
}.
$data .= '}';
- Use the ternary operator.
$data .= 'h'.$i.'{' (!empty($size) ? 'font-size: ' .$size. ';' : ''). '}';
The ternary operator evaluates the first argument to either true or false and returns the second or third argument, just like a function call.
Beware: Using ternary operators too much will make your code unreadable, especially when using it inside each other. You can always replace it with a separated IF construct like above for better readability. Plus the ternary operator cannot be easily extended to do more stuff besides returning one of two values.