DAGDA SEARCH | Back to results | Support the Project

php-ast · GitHub

Source: https://github.com/php-ast

@php-ast php-ast Follow More @php-ast php-ast Follow View php-ast's full-sized avatar

php-ast

Follow

Block or report php-ast

Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse More php-ast/README.md

Python Get PHP-AST

PHP-AST PHP version social

Install

pip install  php-ast

exapme

# get bytes php code ast
from php_ast import php_ast
php_ast=php_ast()
php_ast.get_ast(b"<?php phpinfo();?>")
{'status': 'successed', 'ast': {'kind': 'AST_STMT_LIST', 'flags': 0, 'lineno': 1, 'children': [{'kind': 'AST_CALL', 'flags': 0, 'lineno': 1, 'children': {'expr': {'kind': 'AST_NAME', 'flags': 1, 'lineno': 1, 'children': {'name': 'phpinfo'}}, 'args': {'kind': 'AST_ARG_LIST', 'flags': 0, 'lineno': 1, 'children': []}}}]}}



# get php file ast
from php_ast import php_ast
php_ast=php_ast()
php_ast.get_file_ast("/home/11.php")
{'status': 'successed', 'ast': {'kind': 'AST_STMT_LIST', 'flags': 0, 'lineno': 1, 'children': [{'kind': 'AST_CALL', 'flags': 0, 'lineno': 1, 'children': {'expr': {'kind': 'AST_NAME', 'flags': 1, 'lineno': 1, 'children': {'name': 'phpinfo'}}, 'args': {'kind': 'AST_ARG_LIST', 'flags': 0, 'lineno': 1, 'children': []}}}]}}

说明

参考:

Popular repositories Loading

  1. php-ast php-ast Public

    Parsing PHP source code using Python and generating ASTs

    C 6

Something went wrong, please refresh the page to try again.
If the problem persists, check the GitHub status page or contact support.

Uh oh!

There was an error while loading. Please reload this page.