running php file from linux shell vi editor and command line php for non http based files
Submitted by inder on Wed, 11/19/2008 - 14:48.
for creating and executing a php file from ssh you need to PHP installed as binary (CGI) and add something like at top of shell script
[root:inderweb.com]!/usr/bin/php -q
.This is to tell the shell interprator(kernal) that we are using php from bin directory for executing lines of code in script.To get started with a simple php code in shell do following steps:-
- Open shell prompt and go to your directory . e.g [root:inderweb.com ~]
- Open a php file with vi editor e.g [root:inderweb.com ~] vi phpdemo.php
#!/usr/bin/php -q
<?php
print "hello world\n";
?>
press esc and then Shift+zz for saving the file.now you will be back on prompt
![Validate my RSS feed [Valid RSS]](http://feedvalidator.org/images/valid-rss.png)