Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Simple PHP code to duplicate' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Simple PHP code to duplicate
Authored by: sardu_mac on Jan 23, '03 11:14:59AM

If you have the PHP module enabled you can add a similar feature to pages hosted from your OS X machine. Just make a new text file called 'safari.php'. Paste the following contents (from the "<?php" to the "?>" ) into it:

<?php
Header("Content-Type: image/gif");
if(eregi('Safari',$_SERVER['HTTP_USER_AGENT'])) {
readfile('safari.gif'); // this image gets sent for Safari
} else {
readfile('notsafari.gif'); // this image for other browsers
} ?>

Save it wherever you keep your web images.
Now drop a 'safari.gif' and a 'notsafari.gif' in the same directory.
Add an image tag to your page, using the .php file as the image source:
<img src="url://sitename/location/of/your/images/safari.php">

See http://developer.apple.com/internet/macosx/php.html for information on setting up PHP.

This tiny snippet is meant for OS X users new to PHP, allowing them to add this simple feature to a local page. Anything longer probably belongs on a PHP site, not here... Rob can scold me if I'm wrong. :-)



[ Reply to This | # ]