PHP code example of ircmaxell / php-c-parser

1. Go to this page and download the library: Download ircmaxell/php-c-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ircmaxell / php-c-parser example snippets


$parser = new PHPCParser\CParser;

$ast = $parser->parse('path/to/file');

$parser = new PHPCParser\CParser;

$context = new PHPCParser\Context;
// #define A 42
$context->defineInt('A', 42);
// #define B "testing"
$context->defineString('B', "testing");
// #define C testing
$context->defineIdentifier('C', 'testing');
// etc... 

$ast = $parser->parse('path/to/file', $context);