Get current PHP API

One method to know if the script being executed has been started through cli, apache or any other API is to use PHP_SAPI:

if (PHP_SAPI != ‘cli’) { … }

will ensure that the script is executed in a command-line context before doing what’s inside the brackets.


Related Posts

Memcache(d) to store PHP sessions

Edit: as of July 2014, there is a recent article discussing the use...

Choosing a PHP PDF generation library for Chamilo

2014 update: This article is outdated. To date, the library that matches most...

Quick Contact Form