Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Feb 142010
 

How to prevent PHP script from running in Apache

Answer:

If you have a PHP script and want it run under in command line only, not in the web server context, you can use the following method.

<?php

if ( php_sapi_name() != "cli" ) {
    print "This script must be run from the command line\n";
    exit();
}

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>