Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Stand alone PHP programs
It always seems a shame when people develop a lot of code in PHP then want to use it standalone ... so they rewrite it in some other language or wrap it in a web page.

PHP is an excellent stand alone language; it wasn't designed for that use, but it does a mighty fine job if you've already got files full of functions that you want to use away from as well as on the web. Here's a sampple stand alone PHP program:


#!/usr/bin/php -q

The world of Belgian dressing

<?php

$interact = fopen("php://stdin","r");
for ($k=1; $k<11; $k++) {
print "$k dollops of mayonnaise\n";
$line = fgets($interact,1024);
}

?>

and there's a chip in there somewhere


Two notes:

1. The -q command line option supresses headers so that you don't get a "content type" line

2. The special URL php://stdin allows you to open the keyboard for read, thus it allows you to write a truly interactive program.
(written 2005-10-18 02:26:23)

 
Associated topics are indexed under
H999 - Additional PHP Material
H310 - PHP - Putting it all together
W604 - Web and Intranet - Beyond the Server

Back to
Tell them three times
Previous and next
or
Horse's mouth home
Forward to
Yesterday was Kiss and Ride

Some other Articles
Are you free on 29th October - Charity ball
And it gets even better
I wanna be a Python trainer
Yesterday was Kiss and Ride
Stand alone PHP programs
Tell them three times
Separating 'per instance' data from binaries and web sites
Changing Tomcat's web.xml and reloading a web application
Technical Loneliness
Splitting the difference
1636 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho