PHP Classes

File: example/index.php

Recommend this page to a friend!
  Classes of Francisco Núñez   PHP Web or Cli Detect   example/index.php   Download  
File: example/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Web or Cli Detect
Detect if PHP is running from CLI or a Web server
Author: By
Last change:
Date: 2 years ago
Size: 361 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
IcarosNet\WebCLIDetector\WebCLIDetector;

require_once
__DIR__."/../vendor/autoload.php";

$wc_detector = new WebCLIDetector();

if (
$wc_detector->isCLI()) {
    echo
'Running from CLI'.PHP_EOL;
}

if (
$wc_detector->isWEB()) {
    echo
'Running from WEB<br>';
}

echo
'Get Raw Environment: '.$wc_detector->getEnvironment();