Encrypt Online
Theme

PHP Code Formatter

Format PHP source for a selected PHP version in your browser.

Input + output
<?php array_map(function($arg1,$arg2) use ( $var1, $var2 ) { return $arg1+$arg2/($var+$var2); }, array("complex"=>"code","with"=> function() {return "inconsistent";},"formatting"=>"is", "hard" => "to", "maintain"=>true));
PHPFormatBeautify
About the PHP formatter

This page formats PHP source with the Prettier PHP plugin in your browser. Select the PHP version that matches the source before formatting it. Available profiles include PHP 5.0 through 5.4, PHP 5.6, PHP 7.0 through 7.4, and PHP 8.0 through 8.1.

Formatting changes whitespace, indentation, and line breaks. It does not execute the PHP code or prove that the program behaves correctly.

Format PHP code
  1. Paste PHP source into the input editor.
  2. Select the PHP version used by the project.
  3. Select Format.
  4. Review and copy the output.
Review the result

The formatter can reject syntax that is invalid for the selected PHP version. A successful format means the parser accepted the source. Run the project's tests and review the change before replacing a working file.

Related tools
Related guide

Read HTML, Markdown, and Text Conversion Workflows That Preserve Meaning for markup and content-conversion tasks.