title: run script from CLI but prevent running when included
body: <p>I have a php script the I often run using CLI (regular ssh terminal).</p>
  
  <pre><code>&lt;?php
  
      class foo {
          public function __construct() {
              echo("Hello world");
          } 
      }
  
      // script starts here...
      $bar = new foo();
  
  ?&gt;
  </code></pre>
  
  <p>When I run the code using <code>php filename.php</code> I get the <code>Hello world</code> stagnant as expected. Problem is that when i include the file from other php file I get the same thing (which I don't want).</p>
  
  <p>How can I prevent code from running when file include but still use it as a CLI script?</p>