0

I have a script which is running on Apache and also can be executed from command line.

How can i know, on what is php script running, apache or command line?

Havelock
  • 6,913
  • 4
  • 34
  • 42
Tigran Muradyan
  • 402
  • 1
  • 8
  • 24

3 Answers3

1

There is a constant build in PHP that you can use PHP_SAPI. If you are on the commandline the value of this constant is cli than you are on the command line. Every other value like cgi, cgi-fcgi, etc.

andreashager
  • 667
  • 3
  • 9
0

Why not add a parameter and only pass it when invoking from the command line?

http://php.net/manual/de/reserved.variables.argv.php

Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
-3

Create a page upload it and browse to it.

See page contents below.

<?php phpinfo(); ?>
Gfoxxy93
  • 1
  • 1