PHP Formatter
Re-indents PHP code safely without touching strings, comments, or inline HTML.
Test printf and sprintf format strings with your own arguments and see the output as you type. Each placeholder is broken down into its flags, width, precision, and type.
| Placeholder | Argument | Flags | Width | Precision | Result |
|---|
%-10s|%08.3f, and put one value per line in Arguments.A placeholder has the form %[argnum$][flags][width][.precision]type.
- aligns left, + always shows the sign, a space puts a space before positive numbers, 0 pads with zeros, and # adds 0x or 0 prefixes in C. In PHP, 'c pads with the character c.f and e, the number of significant digits for g, and the maximum length for s.%2$s uses the second argument, whatever its position. %% prints a percent sign.%d with 3.9 prints 3.%05.1f with 3.14159 gives 003.1.%-8s| with abc gives abc |.%+d with 42 gives +42.%x with 255 gives ff, and %#X in C gives 0XFF.%.2e with 12345.678 gives 1.23e+04.%'*10s with php gives *******php, and %b with 5 gives 101.%2$s %1$s with world and hello gives hello world.l, ll, and h are accepted and ignored, because the numbers here are not limited to a fixed size. Overflow behaviour isn't simulated.%n and %p are not supported, because they depend on memory addresses.printf prints the formatted text straight away. sprintf returns it as a string. The format rules are the same.
Write %%. A single % starts a placeholder.
%d formats an integer, so the decimal part is dropped, not rounded. Use %.0f to round instead.
Their % style follows the same core rules, so most format strings behave the same. Python's {} format and f-strings use a different syntax.
Often used together with the Printf Format Tester.
Re-indents PHP code safely without touching strings, comments, or inline HTML.
Converts PHP serialized strings to readable JSON and back, safely.
Highlights regex matches live, lists capture groups and offsets, and previews replacements.