PHP Doku:: Tokenizer Funktionen - ref.tokenizer.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenTokenizer FunktionenTokenizer Funktionen

Ein Service von Reinhard Neidl - Webprogrammierung.

Tokenizer Funktionen

<<Beispiele

token_get_all>>


UnterSeiten:

Inhaltsverzeichnis


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
lists at 5etdemi dot com
23.07.2005 10:33
The tokenizer functions are quite powerful. For example, you can retrieve all of the methods in a given class using an algorithm like:

for each token:
if token is T_FUNCTION then start buffer
if buffer is started then add the current string to the buffer
if token is ( stop buffer

And the great thing is that the class methods will have the right case, so it's a good way to get around the limitations with get_class_methods returning lowercase method names. Also since using a similar algorithm you can read the arguments of a function you can implement Reflections-like functionality into PHP4.

Finally you can use it as a simpler method of extracting Javadoc out of a class file to generate documentation. The util/MethodTable.php class in AMFPHP (http://www.amfphp.org) uses the tokenizer functions to create a method table with all of the arguments, a description, return type, etc. and from that method table it can generate ActionScript that matches the PHP, but it could also be fitted to generate JavaScript, documentation files, or basically anything you put your mind to. I can also see that this could be the base for a class -> WSDL file generator.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)