1 |
<input type="text" onkeypress="return event.charCode >= 48 && event.charCode <= 57" onblur="this.value = minmax(this.value, 1, 31);" > |
Php yanlış girdiyi doğru hale getirme (levenshtein Fonksiyonu)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<?php // girdi yanlış yazılmış olsun $input = 'carrrot'; // bir sözcük dizisiyle karşılaştıralım $words = array('apple','pineapple','banana','orange', 'radish','carrot','pea','bean','potato'); // en kısa mesafenin bulunamaması durumu $shortest = -1; // En kısa mesafeyi bulmak için döngü foreach ($words as $word) { // girdi ile sözcük arasındaki mesafeyi hesaplatalım $lev = levenshtein($input, $word); // Bir eşleşme var mı bakalım if ($lev == 0) { // en yakın sözcük bu olacak (tam eşleşme) $closest = $word; $shortest = 0; // Tam bir eşleşme bulduğumuza göre döngüden çıkalım break; } // Eğer bu mesafe bir öncekinden kısaysa // veya en kısa mesafe henüz bulunamadıysa if ($lev <= $shortest || $shortest < 0) { // en yakın eşleşmeyi ve en kısa mesafeyi tanımlayalım $closest = $word; $shortest = $lev; } } echo "Girdi: $input\n"; if ($shortest == 0) { echo "Tam eşleşme bulundu: $closest\n"; } else { echo "Doğrusu bu olabilir mi?: $closest\n"; } ?> |
Kaynak : http://php.net/manual/tr/function.levenshtein.php
İnclude ile Template i değişkene atama
1 2 3 4 5 6 |
ob_start(); // Start output buffer capture. include("yourtemplate.php"); // Include your template. $output = ob_get_contents(); // This contains the output of yourtemplate.php // Manipulate $output... ob_end_clean(); // Clear the buffer. echo $output; // Print everything. |
1 |
https://stackoverflow.com/questions/18190386/php-file-get-contents-a-php-file-with-include?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa |
“Warning: PDOStatement::execute(): Unknown type 245 sent by the server. Please send a report to the developers in” Hatasının Çözümü
1 |
SELECT CAST(photos AS CHAR) AS photos FROM users |
Mysql datetime equal current date
1 |
SELECT * FROM users WHERE DATE(datetime) = DATE(NOW()) |
GROUP BY incompatible with sql_mode=only_full_group_by Hatası
Bu hatayı almaya başladıysanız mysql 5.7 ile tanışmış olmalısınız 🙂 Bu hatayı çözmek için birkaç yöntem mevcut. 1) Phpmyadmin’den ayarlama – Phpmyadmin’den “Değişkenler” kısmına gelip arama kısmına “sql_mode” yazın. Düzenle butonuna basın. only_full_group_by kısmını kaldırırsanız hata düzelir. Ama bu çözüm
Google Maps Adresten Konum Bilgilerini Alma (PHP)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?php function get_lat_long($address, $region){ $address = str_replace(" ", "+", $address); $json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=$region"); $json = json_decode($json); // print_r($json);die; $lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'}; $long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'}; return $lat.','.$long; } $latlong = get_lat_long("Konutkent Mahallesi 3029 Cadde ", "Ankara"); echo $latlong; ?> |
PHP Çoklu Dil Desteği
Merhaba arkadaşlar, Günümüzde artık birçok sitede çoklu dil desteğini görmekteyiz. Çoklu dil desteği için birçok yöntem kullanılıyor. Bunlardan birkaçı, kelimeleri değişken olarak global bir şekilde tutmak, her dil için ayrı klasörler oluşturmak gibi yöntemler geliyor. Başlarda bende kelimeleri global değişkenler