Application of printf and sprintf

WBOY
Release: 2016-08-08 09:20:44
Original
906 people have browsed it

<?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);
Copy after login
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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!