RE: [PHP-DEV] Tip of the day: embedding php code in scripts

From: Date: Mon, 20 May 2002 23:42:07 +0000
Subject: RE: [PHP-DEV] Tip of the day: embedding php code in scripts
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-84205@lists.php.net to get a copy of this message
Without output buffering, the script would output: exec $0 $@ Hello World! The -q option could be added to make it work with cgi as well as cli, but the point of the output buffering is to kill the line of shell script that PHP would treat as plain text to display. - Stig On Mon, 2002-05-20 at 19:42, Dan Hardiker wrote: > Im unsure of the need for output_buffering... if its to kill the headers, > then "php -q" will suppress those. > In any case, I believe the Stig is asking if anyone has thought of > embedding php scripts inside typical /bin/sh shell scripts. EG: > #!/bin/sh > //- script stuff here -\\ > exec /usr/local/bin/php -q > <?php > print "Hello World!\n"; > ?> > //- script stuff here -\\ > > Unless Im mistaken ... for which I appologise. > > - Dan > > > > From: Stig S. Bakken [mailto:ssb@fast.no] > >> Did anyone come up with this one before or do I have a "first post"? > >> :-) > >> > >> #!/bin/sh > >> exec php -d output_buffering=1 $0 $@ > >> <?php > >> ob_end_clean(); > >> print "Hello World!\n"; > >> ?> > > > > Or the shorter (and faster) version: > > > > #!/usr/local/bin/php -d output_buffering=1 > > <?php > > ob_end_clean(); > > print "Hello World!\n"; > > ?> > > > > Or perhaps you had something else in mind? > > > > I believe most (all?) modern Unix implementations do #! handling > > in the kernel's exec() function, so you avoid the /bin/sh startup. > > > > > > > > -- > > PHP Development Mailing List <http://www.php.net/> > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > Dan Hardiker [dhardiker@staff.firstcreative.net] > ADAM Software & Systems Engineer > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.dev (#84205) next »