Skip to content
Advertisement

Running php script (php function) in linux bash

How we run php script using Linux bash?

php file test.php

test.php contains:

<?php echo "hellon" ?>

Advertisement

Answer

From the command line, enter this:

php -f filename.php

Make sure that filename.php both includes and executes the function you want to test. Anything you echo out will appear in the console, including errors.

Be wary that often the php.ini for Apache PHP is different from CLI PHP (command line interface).

Reference: https://secure.php.net/manual/en/features.commandline.usage.php

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement