Cynosure.X International LLC


Add Comment | Related Links | TrackBack
Related Content

Overriding the Interpreter

You can usually specify the PHP interpreter on the first line of your PHP script. Then you can execute the PHP script directly on the command-line. The following example Hello World program uses that feature:

#!/usr/local/bin/php -q

echo "Hello World!\n";

But I found that on some web hosting servers, both PHP 4 and PHP 5 are installed. Usually, /usr/local/bin/php points to PHP 4. My scripts require PHP 5. To change the default location of the PHP 5 interpreter on the first line of the script means I will break the script when I use it on a server where PHP 5 is installed at the default location. The best way, I found, around this problem is to override the first line by specifying the right interpreter on the command-line, as shown below:

  /usr/local/bin/php5 HelloWorld.php

Even though the default interpreter is specified on the first line in HelloWorld.php, it is ignored by the executing interpreter on the command-line. Now, I can execute the same script on all servers, once I figure out where PHP 5 is installed.

Chieh Cheng
Wed, 13 Feb 2008 01:35:39 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 7 + 2?
Click button only once, please!


TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

40 Users Online

Hacking Digital Cameras
Fun for Photographers

Amazon Associate

Copyright © 1996 - 2024. All Rights Reserved.