faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

141 of 182 people (77%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do I run PHP from the command line or as a shell script?
How to pass an argument to php run as cgi?
How to change include_path for php run as cgi? (no access to php.ini)
How to encrypt my php code?
How do you install PHP in CGI Mode??? There is no doco on the subject!!!

Jan 19th, 2009 08:51
forum net tr, PHP Man, Philip Olson, George Herson, joshua paul, Nathan Wallace, Son Nguyen, Knud van Eeden, Robert Brown III, http://php.net/security.cgi-bin http://httpd.apache.org/docs/howto/cgi.html.html


To compile a CGI version of PHP simply leave out of your configure
statement any options that specify a non-CGI build, such as --apxs and
--with-apache.  PHP also has a CLI version that's similar (yet subtely
different) to the CGI, you'll use CLI for commandline operations.
For more information on how these work, and how to install them, read
the official documentation:
  Using PHP from the command line:
  ------------------------------------------------------------------
  http://www.php.net/manual/en/features.commandline.php
Once a CGI-version of PHP is installed, $ php -h gives you the command
line parameters. 
Use the !# construction to cause a script to load php.  The syntax is:
    #!/path/to/php
    <?php
        // your php code
    ?>
If you want it to not send the CGI-style headers, add -q:
    #!/path/to/php -q
    <?php
        // your php code
    ?>
To run your php scripts without the "shebang" line, specify "php" with
the script name on the command line: 
    # php -q helloworld.php
    Hello, World.
This way, on a Unix system, you also avoid having to make 
helloworld.php
executable.
You can have both a CGI (i.e. standalone) PHP executable and mod_php on
the same system.  The mod_php module will be used for web serving of
your PHP scripts if this module is loaded by your httpd configuration.
To set up your web server and php.ini for CGI execution of PHP scripts
via the web, you'll need to do more than create a PHP binary.  Read
http://php.net/security.cgi-bin for your options. Read
http://httpd.apache.org/docs/howto/cgi.html.html also for the 
fundamentals.
To execute a PHP script on a win32 system, just cd to the dir that the
script is in and type the script name:
    C:\>myscript.php
Note, however, that if the script is a form that posts back to itself,
the only thing you will get is the form elements echoed to the console.
You will have to hardcode the form field values first if you want to 
see the post in action.
Also, the .php extension should be registered to be executed with
php.exe.
To pass an argument to a cgi php script, e.g.,
    # /tmp/test.php -f
use the $argv array, as in C:
if ($argv[1]=="-f") {
  echo "The first argument is -f.\n";
}
Again, be sure to read the manual page for more information (and
examples) on using PHP from the commandline:
  http://www.php.net/manual/en/features.commandline.php
To dynamically change your php.ini values, see
http://www.php.net/manual/en/function.ini-set.php.  Example use:
    echo "include_path=",ini_get("include_path"),"\n";
    ini_set("include_path","/tmp");
    echo "include_path=",ini_get("include_path"),"\n";
    include "test.php"; // Infinite loop if this code is run from
/tmp/test.php.
To encrypt your PHP code, a few compilers come to mind:
Zend: 
  http://zend.com/store/products/zend-encoder.php
BinaryPHP:
  http://us2.php.net/manual/en/features.commandline.php
Roadsend:
  http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler
=====
http://us3.php.net/features.commandline
hope that help.
http://americanahost.com
http://www.qwesz.com
http://www.videotrtube.com/
http://www.forumnettr.com/forum
http://www.forumnettr.com/
http://www.firmanettr.com/
http://www.thethumbnail.com/
http://www.sextubexvideos.com/