Parsing php requires -


this easy can't seem able figure out now. lets assume have 2 sets of .php files:

set 1, contains files named page1.php, page2.php, ... pagen.php.

set 2, contains files named module1, module2.php, ... modulen.php.

files "set 1" contain non-php code should treated text, , using

<?php require("somefilefromset2.php");?> 

to include respective contents files on set 2. files set 1 never php "required" other file.

also, files "set 2" can required 1 or more files "set 1", can "require" other files, "set 2" only. if somefilefromset2.php getting "required" anotherset2file.php, first cannot require file 's been required (the latter), mean there not circular issues. (i explain (better?) using more sets of files, tried stick 2 simplicity). files set 2 contain non-php code treated text again.

there no other php code in none of files of either set, except

<?php require("somefilefromset2.php");?> 

calls. want achieve find way , perform kind of building process, when run each file "set 1", can parse php requires on , on modules includes, , new output file "page1-with-modules.whatever" php require "free" , contain code module files.

edit: adding basic sample make more clear achieve.

contents of filefromset1.php (ie page1.php) be:

<some no-php code #1> <?php require("somefilefromset2.php");?> <some no-php code #2> 

contents of somefilefromset2.php be:

<some no-php code #3> <?php require("someotherfilefromset2.php");?> <some no-php code #4> 

and someotherfilefromset2.php have:

<some no-php code #5> 

what want achieve parse these requires in files related "filefromset1.php" , output new "php-free" file containing:

<some no-php code #1> <some no-php code #3> <some no-php code #5> <some no-php code #4> <some no-php code #2> 

i solved , pretty simple! since on windows 10 changed powershell's encoding utf-8 running 'chcp65001', , run php.exe command this:

path-to\php.exe ./page1.php >> page1-with-modules.html 

the contents of page1-with-modules.html wanted achieve "page1".


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -