Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Tokenization of namespaced names --EXTENSIONS-- tokenizer --FILE-- <?php $code =..

Decoded Output download

--TEST--
Tokenization of namespaced names
--EXTENSIONS--
tokenizer
--FILE--
<?php

$code = <<<'CODE'
<?php
Foo
Foo\Bar
\Foo\Bar
namespace\Foo
Foo \ Bar
CODE;

foreach (PhpToken::tokenize($code) as $token) {
    echo "{$token->getTokenName()}: \"$token->text\"
";
}

?>
--EXPECT--
T_OPEN_TAG: "<?php
"
T_STRING: "Foo"
T_WHITESPACE: "
"
T_NAME_QUALIFIED: "Foo\Bar"
T_WHITESPACE: "
"
T_NAME_FULLY_QUALIFIED: "\Foo\Bar"
T_WHITESPACE: "
"
T_NAME_RELATIVE: "namespace\Foo"
T_WHITESPACE: "
"
T_STRING: "Foo"
T_WHITESPACE: " "
T_NS_SEPARATOR: "\"
T_WHITESPACE: " "
T_STRING: "Bar"
 ?>

Did this file decode correctly?

Original Code

--TEST--
Tokenization of namespaced names
--EXTENSIONS--
tokenizer
--FILE--
<?php

$code = <<<'CODE'
<?php
Foo
Foo\Bar
\Foo\Bar
namespace\Foo
Foo \ Bar
CODE;

foreach (PhpToken::tokenize($code) as $token) {
    echo "{$token->getTokenName()}: \"$token->text\"\n";
}

?>
--EXPECT--
T_OPEN_TAG: "<?php
"
T_STRING: "Foo"
T_WHITESPACE: "
"
T_NAME_QUALIFIED: "Foo\Bar"
T_WHITESPACE: "
"
T_NAME_FULLY_QUALIFIED: "\Foo\Bar"
T_WHITESPACE: "
"
T_NAME_RELATIVE: "namespace\Foo"
T_WHITESPACE: "
"
T_STRING: "Foo"
T_WHITESPACE: " "
T_NS_SEPARATOR: "\"
T_WHITESPACE: " "
T_STRING: "Bar"

Function Calls

None

Variables

None

Stats

MD5 81f61bec37da4eb512f8f192d5b540c8
Eval Count 0
Decode Time 88 ms