Home >Backend Development >PHP Tutorial >Application of printf and sprintf

Application of printf and sprintf

WBOY
WBOYOriginal
2016-08-08 09:20:44952browse

<?php
printf('b: %b <br>c: %c <br>d: %d <bf>f: %f', 80,80, 80, 80);
echo '<br />';
printf('%0.2f <br>%+d <br>%0.2f <br>', 8, 8, 1235.456);

printf('the cost of %d %s at $%0.2f each is $%0.2f.', 4, 'brooms', 8.50, (4*8.50));

echo '<br>';
$tax = 30;
printf('The tax rate is %0.2f%%', $tax);
rrree

The above has introduced the application of printf and sprintf, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn