Example 1 — Fill In Placeholders
Mix text with values using %s and %d.
<?php
printf("Name: %s, Age: %d" . PHP_EOL, "Ann", 25); How It Works
- Write the format. %s is for text and %d is for whole numbers.
- Pass the values. They fill the placeholders in order.
- PHP builds the string. Ann goes first, then 25.
- It prints right away. No echo is needed.

