Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to differentiate between http and cli requests?

The title is quiet straightforward. I have to know on server side if the script called through HTTP request or by command line. I could examine the $_SERVER['argv'] or $_SERVER['argc'].
What is the pragmatic way to do that?

like image 777
erenon Avatar asked Jan 31 '10 19:01

erenon


1 Answers

http://us3.php.net/manual/en/function.php-sapi-name.php

<?php
echo PHP_SAPI;
echo php_sapi_name();
?>
like image 174
Matthew Avatar answered Nov 12 '22 12:11

Matthew