sprintf is a very practical formatted string function in PHP. It can embed variables into strings according to the specified format and is widely used in log output, template rendering, URL generation and other scenarios. However, when beginners use sprintf to output a percent sign, they often step on the pit: outputting % directly will not be as expected. This article will explain in detail how to correctly use sprintf to output percent signs and the principles behind it.