Created
June 25, 2012 09:01
-
-
Save 01-Scripts/2987505 to your computer and use it in GitHub Desktop.
Ausgabe eines zufälligen Bildes aus einem Unterverzeichnis per PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"> | |
<head> | |
<title>Codeschnipsel: Zufallsbild mit PHP ausgeben - by 01-Scripts.de</title> | |
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> | |
<meta name="author" content="Michael Lorer - www.01-scripts.de" /> | |
<meta name="description" content="Ausgabe eines zufälligen Bildes aus einem Unterverzeichnis per PHP" /> | |
<!-- Lizenziert unter Creative Commons Namensnennung 3.0 Deutschland (CC BY 3.0) | |
http://creativecommons.org/licenses/by/3.0/de/ --> | |
</head> | |
<body> | |
<h1>Codeschnipsel: Zufallsbild mit PHP ausgeben - by 01-Scripts.de</h1> | |
<?php | |
$zufall = mt_rand(1, 5); // Erzeugt eine Zufallszahl zwischen 1 und 5 | |
?> | |
<!-- An dieser Stelle geben wir nun das Zufallsbild aus: --> | |
<img src="images/<?PHP echo $zufall; ?>.jpg" alt="Alternativtext zum Bild" /> | |
<br /><hr /><br /> | |
<!-- Wenn wir mit Thumbnails arbeiten wollen müssen wir folgenden Code verwenden: --> | |
<a href="images/<?PHP echo $zufall; ?>.jpg"> | |
<img src="images/<?PHP echo $zufall; ?>_small.jpg" alt="Alternativtext zum Bild" /> | |
</a> | |
<p style="margin-top: 100px;">Dieser Beitrag ist unter der <a href="http://creativecommons.org/licenses/by/3.0/de/">Creative Commons Namensnennung 3.0 Deutschland</a> lizensiert.<br /> | |
Bearbeitung, Nutzung & Verbreitung ist ausdrücklich gestattet.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment