Executing PHP code from a command line
Moderator: General Moderators
Executing PHP code from a command line
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?
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Yes, read more here:
http://www.php.net/features.commandline
also i found this in the comments:
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!