PHP Strings

Leading zeroes

// Prints a leading zero if the `$number` is a single digit.
echo sprintf('%02d', $number);

Variables in strings

Variable

echo "The quick brown fox $my_variable over the lazy dog.\n";

Array

echo "The quick brown fox {$my_array['animal_action']} over the lazy dog.\n";

Class property

echo "The quick brown fox $my_class->my_text_var over the lazy dog.\n";