PHP Interactive - loading a file from the command line

Is there a way from a bash script and / or terminal to run php interactively and upload to a predefined file at the same time?

Essentially, I want to take the following two steps in one step:

shell# php -a Interactive mode enabled php > require_once('ABSOLUTE_PATH_TO_FILE'); 

I tried using php -a --file='ABSOLUTE_PATH_TO_FILE' , but the functions I want to load do not become available interactively.

+5
source share
1 answer

If you have a test.php file with this content

 <?php function asd() { echo "Hi!"; } ?> 

You should use:

 php -a -d auto_prepend_file=test.php 
+12
source

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


All Articles