Skip to main content

Posts

Showing posts with the label php

Array key ကုိ random ယူျခင္း။

php array ထဲက keys ေတြကုိ random ထုတ္ခ်င္တဲ့အခ်ိန္ေတြရွိမွာပါ။ ေအာက္က ပံုစံအတုိင္းသံုးရင္ ဆင္ေျပပါတယ္။ <?php             $cities = array(1 => yangon , 2 =>  mandalay , 3 => Pathein , 4 =>  Dawei);               $random_key =  array_rand( $cities, 1 ) ;              print $random_key; ?> array_rand ဆိုတဲ့ function သံုးရမွာပါ။  $cities က ေတာ့ ကုိယ္သံုးခ်င္တဲ့ array ျဖစ္ျပီး 1 က ေတာ့ ဘယ္ႏွစ္ခုဆြဲမလဲလုိ့ ေရြးရတာျဖစ္ပါတယ္။ အေသးစိတ္ကုိ php.net မွာ သြားဖတ္ႏုိင္ပါတယ္။ Source : http://www.homeandlearn.co.uk/php/php6p7.html

Remove index.php in url (.htaccess)

php ျဖင့္ေရးထားတဲ့ application မွာ index.php ေဖ်ာက္ခ်င္ရင္ .htaccess ထဲမွာ ေအာက္ပါအတုိင္းေရးျပီး သံုးလုိက္ရင္ဆင္ေျပပါျပီ။ <IfModule mod_rewrite.c>     Options +FollowSymLinks -Indexes     RewriteEngine On     RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </IfModule> /etc/apache2/site-available ထဲက default မွ ာေအာက္က အတုိင္း လုိအပ္သလိုျဖည့္ေပးလုိက္ရင္ရပါျပီ။ <VirtualHost *:80> ServerName www.yts.me DocumentRoot /var/www/ <Directory /var/www> AllowOverride all </Directory> </VirtualHost> all ဆို စာသားက အေရးၾကီးဆံုးပါ။ A အၾကီးဆုိရင္ေတာင္အလုပ္မလုပ္ဘူး ။