Here is the code:
if (isset($_POST['state']) && count($err) > 0) {
echo "<p>";
array_walk($err, create_function('&$value', 'printf("$value<br />");'));
echo "<br /><a href=\"/#contacto\">Volver</a></p>";
}
The problem:
The code works as expected, but it insists on printing linebreaks like <br>. Refusing to print them like <br />, as if it didn’t like the XHTML guidelines.
Any other forward slash / (in a closing tag) is printed correctly.
I have already tried nl2br() with the second parameter set to ‘true’. I’ve tried escaping them with a backslash \ (and then the backslash is printed but not the forward slash). I’ve tried escaping them with another forward slash (curiously enough it didn’t comment the rest of the line), and passed the strings through echo, printf, and trim to no avail.
Can anyone tell me what is going on?
To simplify your logic, you could just use:
If you’ve tried all those techniques to no avail, are you sure there’s an issue with your code? Maybe you should try viewing your code using another browser, or even with some command-line tool such as curl: