2

We are running a php client command. php xx yy zz run just fine but not its counter parts (/usr/bin/php and /bin/php) which give very weird error.

I am so confused row, given that :

command -v php || which php || type -p php 

=> /usr/bin/php (( all 3 of them)

whereis php 

=> php: /usr/bin/php /usr/bin/php7.3 /usr/lib/php /etc/php /usr/include/php /usr/share/php /usr/share/php7.3-xmlrpc /usr/share/php7.3-imap /usr/share/php7.3-opcache /usr/share/php7.3-zip /usr/share/php7.3-curl /usr/share/php7.3-common /usr/share/php7.3-bcmath /usr/share/php7.3-soap /usr/share/php7.2-xml /usr/share/php7.3-gd /usr/share/php7.3-mysql /usr/share/php7.3-mbstring /usr/share/php7.2-common /usr/share/php7.3-json /usr/share/php7.3-xml /usr/share/php7.3-readline /usr/share/man/man1/php.1.gz

type -a php 

=> php is /usr/bin/php

php is /bin/php

Why my script works with "php" but /usr/bin/php or /bin/php. What are the different between them ?

2
  • Difference between what? Your output shows only one php command, namely /usr/bin/php. All others are just directories, configuration files, libraries, manuals, etc. What is the weird error you get when you use the given commands? Don't interpret it, just run the commands and copy&paste the output into your question. Commented Dec 9, 2019 at 8:04
  • i would suggest to use whereis php Commented Dec 9, 2019 at 9:11

1 Answer 1

2

Basically, there are two ways php is installed on your lets say Linux system. For apache use for webserver. And for cli use.

You can check the web version using <?php phpinfo(); ?> function for a web page.

For cli you can check path and version using which php and php --version respactivitly.

Difference php-cgi and php-cli

PHP CLI is the command-line interface for PHP (e.g. for creating standalone applications) PHP CGI is the common gateway interface for PHP (e.g. for web applications) Source: https://stackoverflow.com/a/9315749/2107145

You might want to read this thread https://stackoverflow.com/a/45493656/2107145 for details of all php version.

Explaination of commands

type: will display information about command

which: will display binary path of given command

command: display information about command

whereis: will find all binaries of given command say php

thats all for now.

Ask me if you need to know more.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.