Input PHP Code
4 Spaces Indent
Tab Indent
2 Spaces Indent
4 Spaces Indent
8 Spaces Indent
1
Processing Result
1

Instructions & PHP Knowledge

How to use this tool

  • Auto Response: Paste or modify the code in the left input box, and the system will automatically format it for you after you stop typing.
  • PHP Format: Paste messy PHP code on the left, the system will automatically parse tags like <?php and restore standard indentation and code block hierarchy.
  • Save Locally: Click the "Save Locally" button on the right to directly download the formatted code as a .php file.

PHP Code Specifications (PSR-12)

  • Indentation: It is recommended to use 4 spaces for indentation, tabs are prohibited.
  • PHP Tags: All PHP code must be contained within <?php ... ?> tags or the shorthand output tag <?= ... ?>. If it's a pure PHP file, it's recommended to omit the closing ?>.
  • Control Structures: For control structures like if, else, while, for, the left brace { should be on the same line as the control statement, preceded by a space.