Previous Up Next
How to use PHP_Beautifier How to use PHP_Beautifier Command Line use

Script use

Instructions and examples of use of the class PHP_Beautifier inside a Script

Claudio Bustos cdx@users.sourceforge.com Jens Bierkandt scortch@users.sourceforge.com

Script use

  • Create a instance of the object

  • Define the input and output files

  • Optional: Set one or more Filter. They are processed in LIFO order (last in, first out)

  • Optional: Set the indent char, number of chars to indent and/or the newline char

  • Process the file

  • Get it, save it or show it.

  1. // Create the instance
  2. $oBeautifier new PHP_Beautifier()
  3. // Add a filter, without any parameter
  4. $oBeautifier->addFilter('ArraySimple');
  5. // Add another filter, with one parameter
  6. $oBeautifier->addFilter('Pear',array('add_header'=>'php'));
  7. // Set the indent char, number of chars to indent and newline char
  8. $oBeautifier->setIndentChar(' ');
  9. $oBeautifier->setIndentNumber(4);
  10. $oBeautifier->setNewLine("\n");
  11. // Define the input file
  12. $oBeautifier->setInputFile(__FILE__)
  13. // Define an output file.
  14. $oBeautifier->setOutputFile(__FILE__.'.beautified.php')
  15. // Process the file. DON'T FORGET TO USE IT
  16. $oBeautifier->process();
  17. // Show the file (echo to screen)
  18. $oBeautifier->show();
  19. // Save the file
  20. $oBeautifier->save();

For more information, see the documentation for PHP_Beautifier

Previous Up Next
How to use PHP_Beautifier How to use PHP_Beautifier Command Line use

Documentation generated on Mon, 31 May 2010 16:16:02 -0400 by phpDocumentor 1.4.3