- token_get_all: documentation ( source)
- print_r: documentation ( source)
<?php
class Token
{
function __construct($type = null, $content, $line = null){
$this->type = $type;
$this->content = $content;
$this->line = $line;
}
}
$tokens = token_get_all('<?php foo > bar isset($var)');
foreach($tokens as $offset => $token){
$tokens[$offset] = is_array($token) ? new Token($token[0], $token[1], $token[2]) : new Token(null, $token, null);
}
print_r($tokens);