Install argc / argv and enable PHP CLI script

If I have a CLI script foo written in PHP that requires various command line parameters, can I call foo from another PHP script by first writing to $ argv and $ argc and then executing include('foo')? (Suppose foo starts with <?php, and not the hash-bang directive.)

Even if it works, why is this a bad idea? (except namespace collision).

+3
source share
2 answers

There is no need to write anything in $argv/ $argc- variables will be available for include, as they relate to the main script.

+2
source

, system exec, foo, $argc $argv.

, foo.

, , .

0

Source: https://habr.com/ru/post/1787285/


All Articles