[PHP plugin tutorial]002. Code Package PHP Beautifier use

Source: Internet
Author: User
Tags beautifier pear php beautifier php source code

This program reformat and beautify PHP source code files automatically. The program is Open Source and distributed under the terms of PHP Licence. It's written in PHP 5 and have a command line tool.

PHP Beautifier is a PHP code beautification tool written in PHP.

Detailed description of the framework address: http://beautifyphp.sourceforge.net/

Other Related downloads:

php Code beautifier download ,php beautifier download

Other than to say, do not talk about conventional installation methods, we can easily install and use pear.

Below, let's talk about < How to install PHP beautifier under Windows? >

Installation steps

1. First, make sure that pearis installed in the PHP environment, and if not, refer to the article "PHP Plugin Tutorial]001.pear Package Manager".

2.pear installation of PHP Beautifier:

In a networked environment, the cmd command line runs pear install php_beautifier-0.1.15, automatically downloads the package and installs it.

Normally, as soon as the install OKappears, the installation is successful "":)

How do I use it?

Once installed, you can run php_beautifier-h on the cmd command line to see the instructions for use.

Next, we can run the command to format our messy code.

Example:

For example, there is a messy and extremely coarse foo.php file:

<?phperror_reporting(0);functionShutdown_handler () {if($error=Error_get_last ()) {              Print_r($error );} }  register_shutdown_function(' Shutdown_handler ' ); classfoo{ Public $bar= ' Hello world! ';  Public function__construct () {}}Echo Var_export(NewFoo (),true ); ?>

With Php_beautifier, execute the command:

Php_beautifier-t < file path to format >\foo.php < format file path >\foo.beautiful.php

During execution, it may be reported that "notice:use of undefined constant t_namespace-assumed ' t_namespace ' in E:\php5\PEAR\PHP\Beautifier.php o N Line 377 ".

This is because t_namespace This constant is defined in the php5.3 species, if not 5.3 version will appear this notice, can be ignored, does not affect the code formatting.

At this point we can see the foo.php formatted code file foo.beautiful.php:

<?PHPerror_reporting(0); functionShutdown_handler () {if($error=Error_get_last ()) {          Print_r($error); }  }  register_shutdown_function(' Shutdown_handler '); classFoo { Public $bar= ' Hello world! ';  Public function__construct () {}}Echo Var_export(NewFoo (),true); ?>

This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4677678.html

[PHP plugin tutorial]002. Code Package PHP Beautifier use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.