# Printf() question

**URL:** <https://forum.kirupa.com/t/printf-question/152161>\
**Category:** Uncategorized\
**Created:** [June 21, 2005, 7:04pm UTC](https://forum.kirupa.com/t/printf-question/152161 "2005-06-21T19:04:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CagedApe](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@CagedApe](https://forum.kirupa.com/u/CagedApe)\
**Post date:** [June 21, 2005, 7:04pm UTC](https://forum.kirupa.com/t/printf-question/152161/1 "2005-06-21T19:04:08Z")

</div>

I’m reading a book on PHP and came across this really wierd example of code with no real explanation on what it means or how to use it.

The piece of code I’m looking at is:

```auto
<?php
$hamburger = 4.95;
$milkshake = 1.95;
$cola = .85;
$food = 2 * $hamburger + $milkshake + $cola;
$tax = $food * .075;
$tip = $food * .16;
printf("**%1d %9s at \$%.2f each: \$%.2f
**", 2, 'Hamburger', $hamburger, 2 * $hamburger);
printf("**%1d %9s at \$%.2f each: \$%.2f
**", 1, 'Milkshake', $milkshake, $milkshake);
printf("**%1d %9s at \$%.2f each: \$%.2f
**", 1, 'Cola', $cola, $cola);
printf("**%25s: \$%.2f
**", 'Food and Drink Total', $food);
printf("**%25s: \$%.2f
**", 'Total with Tax', $food + $tax);
printf("**%25s: \$%.2f
**", 'Total with Tax and Tip', $food + $tax + $tip);
?>

```

The parts I don’t understand are bolded. Could someone please explain to me how you use them? I’m completely lost by this.

The example can be seen in action [here.](http://www.cagedape.com/test.php)
