| Home | Downloads | Documentation | Plugins | Spinoff Projects | Mailing List |
Running phcOnce you have installed phc, run it by typing ./phc You should see something like
phc 0.1.6
Usage: phc [OPTIONS]... [FILES]...
-h, --help Print help and exit
--full-help Print help, including hidden options, and exit
-V, --version Print version and exit
--dump-php Dump PHP code back immediately after parsing to
standard output (pretty printing)
(default=off)
--dump-ast-dot Dump the AST from the source in dot format
(default=off)
--dump-ast-xml Dump the AST from the source in XML format
(default=off)
--compile-time-includes When possible, replace include() statements with
the parsed contents of the specified file
(default=off)
--tab=STRING String to use for tabs while unparsing
(default=` ')
(the exact output will depend on the version of phc) Now write a very small PHP script, for example <? echo "Hello world!"; ?> and store it in a file, for example in helloworld.php. Then run phc as follows: ./phc --dump-php helloworld.php This should output a pretty-printed version of your PHP script back to standard output: <?php echo "Hello world!"; ?> Graphical Outputphc represents PHP scripts internally as trees (this is further explained in Tutorial 1). If you have a DOT viewer installed on your system (for example, graphviz), you can view this tree graphically. First, ask phc to output the tree in DOT format: ./phc --dump-ast-dot helloworld.php > helloworld.dot You can then view the tree (helloworld.dot) using Graphviz. In most Unix/Linux systems, you should be able to do dotty helloworld.dot And you should see the tree (it should look similar to the one we generated). Writing and Reading XMLphc can also output an XML representation of the tree. You can use this representation if you want to process PHP scripts without using the phc framework, but yet using the phc abstract representation of PHP scripts. To generate an XML version of the tree, run ./phc --dump-ast-xml helloworld.php > helloworld.xml phc can also read the XML back in, after which all the usual features of phc are again available; in particular, it is possible to read an XML file, and write PHP syntax. To convert the XML file we just generated back to PHP syntax, run ./phc --read-ast-xml --dump-php helloworld.xml The generated XML uses the schema http://www.phpcompiler.org/phc-1.0. Compile-time Includes phc now has initial support for
compile-time processing of PHP's ./phc --compile-time-includes script_with_includes.php The include support is intended to mimic PHP's include built-in, as far as can be achieved at compile time. phc supports:
|
| $LastChangedDate: 2006-09-08 12:24:58 +0100 (Fri, 08 Sep 2006) $. Contents © the authors. |