I use gettext to translate my user interface. I'd like to write symbol %
as part of a UI caption in a string, but since it has a special meaning, does not works as expected. How can I escape percent symbols?
\ is a special character within a string used for escaping. "\" does now work because it is escaping the second " . To get a literal \ you need to escape it using \ .
In PHP, an escape sequence starts with a backslash \ . Escape sequences apply to double-quoted strings. A single-quoted string only uses the escape sequences for a single quote or a backslash. Here are some common escape sequences for double-quoted strings: \" for a double quote.
Use %%
to escape %.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With