Php ile rastgele fotoğraf gösterme - Php ile sayfa her yenilemede rastgele belirlediğini fotoğrafları göstermek içinkullanabileceğiniz bir hazır kod uygulamadır.
//********************* UPDATE LOG *********************\
|| June 03, 2007 --- version 1.1 Released ||
|| - Added $GLB_IMAGE global for accessing address of ||
|| randomized image. ||
|| July 11, 2005 --- version 1.0 Released ||
\********************************************************//
//******************** INSTRUCTIONS ********************\
|| 1. Upload "basic_image_randomizer.php" to the same ||
|| directory as the page you would like to have a ||
|| randomized image on. ||
|| ||
|| 2. Copy and paste the following line into the page ||
|| which will contain the randomized image (at the ||
|| top of the page is fine): ||
|| <? include("basic_image_randomizer.php"); ?> ||
|| ||
|| 3. Copy, paste and edit the following line into the ||
|| image tag where the random image will be displayed ||
|| /<? imageRandom('dir/of/images/', 'types'); ?> ||
|| Replace the "dir/of/images/" with the directory ||
|| where the images are located. Replace types based ||
|| off the following criteria: ||
|| '' --- All images (be warned this will actually ||
|| draw from all the files so make sure ||
|| that only images are located in the dir ||
|| 'jpg' All jpg images ||
|| 'gif' All gif images ||
|| 'png' All png images ||
|| 'jpg,gif,png' (or any combination of two) ||
|| This will yeild all images that have the ||
|| specified extensions. ||
|| ||
|| Any other extension may also be used, but results ||
|| may not be as expected, so it is best to stick to ||
|| the three main web image extensions. ||
|| An example of properly edited and inserted ||
|| code would be: ||
|| ||
|| <img src='/<? imageRandom('img/', 'png,jpg'); ?>' /> ||
|| NOTE: Due to possible server differences you may or ||
|| may not need the forwards slash located between ||
|| the ' and the < (src='/<). If it doesn't work ||
|| with the slash, remove it and reupload. ||
|| ||
|| This will randomly select an image that is either ||
|| a 'png' or 'jpg' from the directory img/ ||
|| ||
|| 4. (OPTIONAL) If you would like to output the image's ||
|| address for display on the page, or inclusion in ||
|| an <a> tag, place the following where you would ||
|| like to have the image's address printed: ||
|| ||
|| <? echo $GLB_IMAGE; ?> ||
|| Example of usage: ||
|| <a href='<? echo $GLB_IMAGE; ?>'>Click to view</a> ||
|| ||
|| 5. Make sure the file is saved with as a ".php" file ||
|| otherwise the script will not work. ||
|| ||
|| 6. Upload the file and view! ||
\********************************************************//
---------------------------------------------------------------------------------
Kod.
<?