mina
mina

Reputation: 35

Run Php Code in Linux

I would like to run some php code in my linux scripts to do some automation.I have searched on Google but I can't find any resources on it.Can anyone suggest a way to do this?

#!/bin/bash
<?php echo "this is a test "?>

Error Message:syntax error near unexpected token 'newline'

Upvotes: 0

Views: 141

Answers (2)

Ken
Ken

Reputation: 78922

#!/usr/bin/php
<?php
echo 'foo';

use which php to find out where your php interpreter is hidden and make sure you can execute your file chmod u+x foo.php

Upvotes: 0

deniskoronets
deniskoronets

Reputation: 540

You can run your script using command in bash on linux:

php /path/to/file.php

also you can put it into some bash script.

Upvotes: 1

Related Questions