Kajal
Kajal

Reputation: 223

php issue when running on linux with dot slash filename format

I have a script (file1.php)in php in linux

#!/usr/bin/php -q
<?php
 echo "hello world" ?> 

when i run in linux (redhat @ bash shell)

>  php file1.php

it works. my php is in /usr/bin/php and its version is 5.3.3)

but when i run

./file1.php

it says

'./file1.php' not present.

my application requires this ('./file1.php') model to work

on my other machine this file works with ('./file1.php') model

why is it so , is there any way to fix this ..

Upvotes: 1

Views: 324

Answers (1)

Orestes
Orestes

Reputation: 356

You should indicate how your file should be executed. In bash, it's done using a shebang Try adding this line add the very top of your php script:

#!/usr/bin/php
<?php echo 'Hello world!';

This would tell bash to run ./file.php as php /fullpath/file.php More info http://en.wikipedia.org/wiki/Shebang_(Unix)

Upvotes: 2

Related Questions