Re: cvs: pear /Text_Wiki/doc BBtest.txt test_Text_Wiki.php
| From: | bertrand Gugger | Date: | Tue, 19 Jul 2005 12:47:17 +0000 |
| Subject: | Re: cvs: pear /Text_Wiki/doc BBtest.txt test_Text_Wiki.php | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-38714@lists.php.net to get a copy of this message | ||
Hi all,
Martin, I prefer comute to the dev-list , so we get perhaps other points of view.
Martin Jansen wrote:
On Mon Jul 18, 2005 at 08:3149PM +0200, bertrand Gugger wrote:I'd suggest something like the following: <?php $html = true; if (php_sapi_name() == "cli") { $html = false; } ?> As said , I don't trust sapi_name to be stable in future ... Just starting now, if I use FC3 distributed php: it's saying: cgi Yes they only distribute the cgi. And next year a new sapi will come out: xapi ... etc ... Definitively, I'll stick on: if (isset($_SERVER['SERVER_NAME'])) { $html = true; what works smoothly with both sapi and both PH4 and 5 ... or ... Give me a good reason not to do that. or some alternative we can trust in the future PHP versions.Martin Jansen wrote:'m really not sure it's an easy/correct way ... How decrypt that in the list of possible sapi_names ? On the other hand, I have to admit $_SERVER['PHP_SELF'] is unsure for portability ... Could I use $_SERVER['SERVER_NAME'] ?On Mon Jul 18, 2005 at 04:3552PM -0000, bertrand GUGGER wrote:Why don't you check for the return value of php_sapi_name() instead?+if ($_SERVER['PHP_SELF']) {+ $html = true;
This of course does not cover exotics such as the embed or activescript SAPIs, but it should suffice for your needs. OK, here it's just a doc/example script, so we could admit it needs to be edited.But I need that elsewhere, and there no edit admissible, also that should run anywhere even with "exotic" SAPIs. I must say, I was/am quite surprised PHP does not furnish an easy function to do that ... Thanks for rising the question anyway. à+ -- bertrand "toggg" Gugger