I am generating a message with sprintf() , which will then be output using the Symfony Console Component in color:
$mask = '<info>%s</info>'; $message = sprintf($mask, 'MyString'); $output->writeln($message);
This usually works (displays the namespace in green). However, if the line ends with a backslash , the closing information tag is ignored:
$message = sprintf($mask, 'MyString\'); $output->writeln($message);
Output:
MyString</info> ^^^^^^^
Obviously, the backslash seems to be some kind of escape character, but how to avoid this? Or how to save the value of the closing tag </info> ?
So far I have tried:
addcslashes('My\String\', '\\') - duplicates inside and one-fy at the end:
My\\String\</info>
\ as an HTML entity, a sequence of HTML objects is simply displayed verbatim, and there is no closing tag:
My\String\
source share