Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/mtcounter/mtcounter.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 1 Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/mtcounter/mtcounter.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 1 Warning: include(): Failed opening '/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/mtcounter/mtcounter.php' for inclusion (include_path='.:/usr/local/php53/lib/php:/storage/content/41/1005641/pear/php') in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 1 Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/links/db.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 2 Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/links/db.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 2 Warning: include(): Failed opening '/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/links/db.php' for inclusion (include_path='.:/usr/local/php53/lib/php:/storage/content/41/1005641/pear/php') in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 2 Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 6 Warning: mysql_query(): A link to the server could not be established in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 6 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 7 نحوه‌ی ایجاد یک سیستم نمایش تصاویر به صورت اتفاقی، توسط PHP :: یک کلیک برای همیشه
بازگشت به صفحه اصلی
بازگشت به صفحه اصلی
نرم افزارهای رایگان
Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/onlyfreewares.com/Persian.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 80 Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/onlyfreewares.com/Persian.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 80 Warning: include(): Failed opening '/mounted-storage/home86a/sub001/sc47358-NYVZ/onlyfreewares.com/Persian.php' for inclusion (include_path='.:/usr/local/php53/lib/php:/storage/content/41/1005641/pear/php') in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 80
لینک دونی
Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/linkdooni/IncLastPosts.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 94 Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/linkdooni/IncLastPosts.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 94 Warning: include(): Failed opening '/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/linkdooni/IncLastPosts.php' for inclusion (include_path='.:/usr/local/php53/lib/php:/storage/content/41/1005641/pear/php') in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 94
لینک های مفید
Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/468X60Ads.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 114 Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/468X60Ads.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 114 Warning: include(): Failed opening '/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/468X60Ads.php' for inclusion (include_path='.:/usr/local/php53/lib/php:/storage/content/41/1005641/pear/php') in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 114
Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/daily/IncLastPosts.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 118 Warning: include(/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/daily/IncLastPosts.php): failed to open stream: No such file or directory in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 118 Warning: include(): Failed opening '/mounted-storage/home86a/sub001/sc47358-NYVZ/azemat.com/weblog/daily/IncLastPosts.php' for inclusion (include_path='.:/usr/local/php53/lib/php:/storage/content/41/1005641/pear/php') in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 118

در اين آموزش شما نحوه ايجاد يك برنامه نمايش تصاوير به صورت اتفاقی را ياد می‌گيريد.
زبان اين برنامه پی‌اچ‌پی می‌باشد و متشكل از چندين خط می‌باشد. برای شروع ابتدا كدهای زير را كپی و در فايلی با نام دلخواه و با پسوند php ذخيره كنيد.

<?php $imagedir = "./image"; $open = opendir( "$imagedir" );

$imgArray = array();

while($file = readdir($open))
{
if( $file != "." && $file != ".." )
{
array_push( $imgArray, $file );
}
}
closedir( $open);

mt_srand( (double)microtime( ) * 20000000 );
$randval = mt_rand( 0, sizeof( $imgArray ) - 1 );

print( "<IMG SRC=\"$imagedir/" . $imgArray[ $randval ] . "\">" );

?>


سپس يك دايركتوری با نام دلخواه ايجاد كنيد و تصاوير خود را در آن قرار دهيد و تغييرات زير را در برنامه ايجاد كنيد.

$imagedir = "./image";


در اين محل نام دايركتوریی كه تصاوير را در آن قرار داده ايد، بنويسيد.

توضيحاتی در مورد برنامه:

$open = opendir( "$imagedir" ); $imgArray = array();


اين قسمت از برنامه دايركتوری تصاوير را باز می‌كند و خط بعدی آن، آرايه را از وجود تصاوير خالی می‌كند.

while($file = readdir($open)) { if( $file != “.” && $file != “..” ) { array_push( $imgArray, $file ); } }closedir( $open);


اين قسمت صحت وجود دايركتوری معرفی شده را مورد بررسی قرار می‌دهد و فايل‌های درون آن‌را می‌خواند.

$randval = mt_rand( 0, sizeof( $imgArray ) - 1 );


در اين خط از برنامه به فايل‌های خوانده شده، ارزش اتفاقی داده می‌شود.


print( "<IMG SRC=\"$imagedir/" . $imgArray[ $randval ] . "\">" );


اين خط به عنوان خط آخر برنامه، وظيفه‌ی چاپ خروجی را دارد.
در صورت داشتن هر گونه سوال يا مشكل، می‌توانيد با ايميل mihankhah at gmail.com تماس بگيريد.

تعداد بازدید ( Fatal error: Call to undefined function entry_counter() in /storage/content/41/1005641/weblog.azemat.com/public_html/archives/005868.php on line 207