Menu
Riverview Church

TOKEN_GET_ALL

Split given source into PHP tokens

SYNTAX

token_get_all ( string $code [, int $flags = 0 ] ) : array

PARAMETERS

code

The PHP source to parse.

flags
TOKEN_PARSE Recognizes the ability to use reserved words in specific contexts.

RETURN

An array of token identifiers.

Each individual token identifier is either a single character (i.e.: ;, ., >, !, etc...) or a three element array containing: the token index in element 0, the string content of the original token in element 1, and the line number in element 2.

EXAMPLES

CODE

Array
(
    [0] => Array
        (
            [0] => 382
            [1] => <?
            [2] => 1
        )

    [1] => Array
        (
            [0] => 385
            [1] =>

            [2] => 1
        )

    [2] => Array
        (
            [0] => 324
            [1] => echo
            [2] => 2
        )

    [3] => Array
        (
            [0] => 385
            [1] =>
            [2] => 2
        )

    [4] => Array
        (
            [0] => 315
            [1] => 'Hello'
            [2] => 2
        )

    [5] => ;
    [6] => Array
        (
            [0] => 385
            [1] =>

            [2] => 2
        )

    [7] => Array
        (
            [0] => 384
            [1] => ?>
            [2] => 3
        )

)

FLAGS | 0

Array
(
    [0] => Array
        (
            [0] => 382
            [1] => <?
            [2] => 1
        )

    [1] => Array
        (
            [0] => 385
            [1] =>

            [2] => 1
        )

    [2] => Array
        (
            [0] => 364
            [1] => class
            [2] => 2
        )

    [3] => Array
        (
            [0] => 385
            [1] =>
            [2] => 2
        )

    [4] => Array
        (
            [0] => 311
            [1] => myclass
            [2] => 2
        )

    [5] => Array
        (
            [0] => 385
            [1] =>

            [2] => 2
        )

    [6] => {
    [7] => Array
        (
            [0] => 385
            [1] =>
    
            [2] => 3
        )

    [8] => Array
        (
            [0] => 344
            [1] => const
            [2] => 4
        )

    [9] => Array
        (
            [0] => 385
            [1] =>
            [2] => 4
        )

    [10] => Array
        (
            [0] => 358
            [1] => PUBLIC
            [2] => 4
        )

    [11] => Array
        (
            [0] => 385
            [1] =>
            [2] => 4
        )

    [12] => =
    [13] => Array
        (
            [0] => 385
            [1] =>
            [2] => 4
        )

    [14] => Array
        (
            [0] => 309
            [1] => 1
            [2] => 4
        )

    [15] => ;
    [16] => Array
        (
            [0] => 385
            [1] =>

            [2] => 4
        )

    [17] => }
    [18] => Array
        (
            [0] => 385
            [1] =>

            [2] => 5
        )

    [19] => Array
        (
            [0] => 384
            [1] => ?>
            [2] => 6
        )

)

FLAGS | TOKEN_PARSE

Array
(
    [0] => Array
        (
            [0] => 382
            [1] => <?
            [2] => 1
        )

    [1] => Array
        (
            [0] => 385
            [1] =>

            [2] => 1
        )

    [2] => Array
        (
            [0] => 364
            [1] => class
            [2] => 2
        )

    [3] => Array
        (
            [0] => 385
            [1] =>
            [2] => 2
        )

    [4] => Array
        (
            [0] => 311
            [1] => myclass
            [2] => 2
        )

    [5] => Array
        (
            [0] => 385
            [1] =>

            [2] => 2
        )

    [6] => {
    [7] => Array
        (
            [0] => 385
            [1] =>
    
            [2] => 3
        )

    [8] => Array
        (
            [0] => 344
            [1] => const
            [2] => 4
        )

    [9] => Array
        (
            [0] => 385
            [1] =>
            [2] => 4
        )

    [10] => Array
        (
            [0] => 311
            [1] => PUBLIC
            [2] => 4
        )

    [11] => Array
        (
            [0] => 385
            [1] =>
            [2] => 4
        )

    [12] => =
    [13] => Array
        (
            [0] => 385
            [1] =>
            [2] => 4
        )

    [14] => Array
        (
            [0] => 309
            [1] => 1
            [2] => 4
        )

    [15] => ;
    [16] => Array
        (
            [0] => 385
            [1] =>

            [2] => 4
        )

    [17] => }
    [18] => Array
        (
            [0] => 385
            [1] =>

            [2] => 5
        )

    [19] => Array
        (
            [0] => 384
            [1] => ?>
            [2] => 6
        )

)

1

1: T_OPEN_TAG: <?
1: T_WHITESPACE:

2: T_CLASS: class
2: T_WHITESPACE:
2: T_STRING: myclass
2: T_WHITESPACE:

{
3: T_WHITESPACE:
    
4: T_CONST: const
4: T_WHITESPACE:
4: T_PUBLIC: PUBLIC
4: T_WHITESPACE:
=
4: T_WHITESPACE:
4: T_LNUMBER: 1
;
4: T_WHITESPACE:

}
5: T_WHITESPACE:

6: T_CLOSE_TAG: ?>

2

1: T_OPEN_TAG: <?
1: T_WHITESPACE:

2: T_CLASS: class
2: T_WHITESPACE:
2: T_STRING: myclass
2: T_WHITESPACE:

{
3: T_WHITESPACE:
    
4: T_CONST: const
4: T_WHITESPACE:
4: T_STRING: PUBLIC
4: T_WHITESPACE:
=
4: T_WHITESPACE:
4: T_LNUMBER: 1
;
4: T_WHITESPACE:

}
5: T_WHITESPACE:

6: T_CLOSE_TAG: ?>

INTERNAL

token_name

EXTERNAL

PHP