Sunday, February 1, 2015

Check if PHP script was executed from command line CLI or not

Simple and fool proof PHP code snippet to detect if the current running script was executed from command line (CLI) or not (most likely browser).



if(is_null($argc)) {
    //NOT CLI
} else {
    //FROM CLI
}

No comments:

Post a Comment