Skip to content
Advertisement

sprintf (PHP) return unwanted character (×) [closed]

I tried the sprintf function in php, but the results were not as expected, add an undesirable character:

JavaScript

unwanted is ×

the results I expected:

JavaScript

This is my code.

JavaScript

If I replace the timestamp string with something else the result will be fine. What’s wrong with timestamp? how to solve it?

thanks.

Advertisement

Answer

Nothing is wrong with sprintf, &times is the HTML entity for the multiplication sign x.

If you really need to display the generated URL as you’re doing now you can either use return htmlentities($url) instead of returning the $url directly, or by changing the sprintf call to :

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement