note 97202 deleted from tutorial.useful by danbrown
| From: | danbrown@php.net | Date: | Thu, 08 Apr 2010 13:33:33 +0000 |
| Subject: | note 97202 deleted from tutorial.useful by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168019@lists.php.net to get a copy of this message | ||
Note Submitter: Damian
----
In the if-else statement used above, you could shorten it a bunch.
Example:
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
echo 'You are using Internet Explorer.<br />';
}
else {
echo 'You are not using Internet Explorer.<br />';
}
?>
Could instead be...
<?php
echo $msg = (!strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) ? 'You are
<b>not</b> using IE.' : 'You are using IE.';
?>
If strpos() returns false, echo out that they are not using IE. Else, tell them they are using IE.