Page 1 of 1

Executing PHP code from a command line

Posted: Thu May 20, 2004 7:57 pm
by Sniper007
Is there any way to execute a chunk of PHP code (to alter an SQL database I have) using a command line? Like, is there some php.exe I can run with some parameters or something?

Posted: Thu May 20, 2004 8:30 pm
by hob_goblin
Yes, read more here:

http://www.php.net/features.commandline

also i found this in the comments:
Just a note for people trying to use interactive mode from the commandline.

The purpose of interactive mode is to parse code snippits without actually leaving php, and it works like this:

[root@localhost php-4.3.4]# php -a
Interactive mode enabled

<?php echo "hi!"; ?>
<note, here we would press CTRL-D to parse everything we've entered so far>
hi!
<?php exit(); ?>
<ctrl-d here again>
[root@localhost php-4.3.4]#

I noticed this somehow got ommited from the docs, hope it helps someone!