Posted By

maurus on 11/30/-1


Tagged

php image textmate imagerotation cookie


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

daniel
vali29


Simple image rotation with PHP


 / Published in: Other
 

  1. /Add before <html> tags
  2. //Script
  3. if ($_COOKIE[\'head\'] != \"\") {
  4. $ausgabe = $_COOKIE[\'head\'];
  5. }
  6. else {
  7. $bilder = array(\"bild1\", \"bild2\", \"bild3\");
  8. $ausgabe = $bilder[rand(0,2)];
  9. setcookie (\"head\", $ausgabe, time()+1000);
  10. }
  11.  
  12.  
  13. //Output
  14. $sufix = \".jpg\";
  15. $dir = \"http://localhost/weblog/covers/\";
  16. if (isset($_COOKIE[head])) {
  17. echo \'<img src=\"\'.$dir.$ausgabe.$sufix.\'\" alt=\"Cover\" />\';
  18. }
  19. else {
  20. echo \'<img src=\"http://localhost/weblog/alt.jpg\" />\';
  21. }

Report this snippet  

You need to login to post a comment.