Welcome Guest, Not a member yet? Register   Sign In
Get all Functions Names of All CONTROLLERS
#4

(This post was last modified: 02-03-2016, 12:06 PM by ivantcholakov.)

Another possible way is using http://www.php.net/manual/en/function.token-get-all.php
but it requires writing code for detection a sequence of tokens, for example: T_PUBLIC T_WHITESPACE T_FUNCTION T_WHITESPACE T_STRING

Edit: Trying how it works:

Code:
$source = <<<EOT
<?php

class MyClass
{
    public function my_nethod_1()
    {
    }

    public function my_nethod_2()
    {
    }
}

EOT;

$tokens = token_get_all($source);

foreach ($tokens as $token) {

    if (is_array($token)) {
        print_r($token); echo '<br />';
    }
}

I have never used the tokenizer, it requires a little bit practicing, but it seems to me a good choice for this task.
Reply


Messages In This Thread
RE: Get all Functions Names of All CONTROLLERS - by ivantcholakov - 02-03-2016, 11:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB