RE: [PHP-DEV] Tip of the day: embedding php code in scripts
| From: | Preston L. Bannister | Date: | Mon, 20 May 2002 17:21:32 +0000 |
| Subject: | RE: [PHP-DEV] Tip of the day: embedding php code in scripts | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-84192@lists.php.net to get a copy of this message | ||
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.