Bu Blogda Ara

29 Ağustos 2010 Pazar

PHP in Array Introduction

PHP Array Introduction

The array functions allow you to manipulate arrays.

PHP supports both simple and multi-dimensional arrays. There are also specific functions for populating arrays from database queries.


Installation

The array functions are part of the PHP core. There is no installation needed to use these functions.


PHP Array Functions

PHP: indicates the earliest version of PHP that supports the function.

Function Description PHP
array() Creates an array 3
array_change_key_case() Returns an array with all keys in lowercase or uppercase 4
array_chunk() Splits an array into chunks of arrays 4
array_combine() Creates an array by using one array for keys and another for its values 5
array_count_values() Returns an array with the number of occurrences for each value 4
array_diff() Compares array values, and returns the differences 4
array_diff_assoc() Compares array keys and values, and returns the differences 4
array_diff_key() Compares array keys, and returns the differences 5
array_diff_uassoc() Compares array keys and values, with an additional user-made function check, and returns the differences 5
array_diff_ukey() Compares array keys, with an additional user-made function check, and returns the differences 5
array_fill() Fills an array with values 4
array_filter() Filters elements of an array using a user-made function 4
array_flip() Exchanges all keys with their associated values in an array 4
array_intersect() Compares array values, and returns the matches 4
array_intersect_assoc() Compares array keys and values, and returns the matches 4
array_intersect_key() Compares array keys, and returns the matches 5
array_intersect_uassoc() Compares array keys and values, with an additional user-made function check, and returns the matches 5
array_intersect_ukey() Compares array keys, with an additional user-made function check, and returns the matches 5
array_key_exists() Checks if the specified key exists in the array 4
array_keys() Returns all the keys of an array 4
array_map() Sends each value of an array to a user-made function, which returns new values 4
array_merge() Merges one or more arrays into one array 4
array_merge_recursive() Merges one or more arrays into one array 4
array_multisort() Sorts multiple or multi-dimensional arrays 4
array_pad() Inserts a specified number of items, with a specified value, to an array 4
array_pop() Deletes the last element of an array 4
array_product() Calculates the product of the values in an array 5
array_push() Inserts one or more elements to the end of an array 4
array_rand() Returns one or more random keys from an array 4
array_reduce() Returns an array as a string, using a user-defined function 4
array_reverse() Returns an array in the reverse order 4
array_search() Searches an array for a given value and returns the key 4
array_shift() Removes the first element from an array, and returns the value of the removed element 4
array_slice() Returns selected parts of an array 4
array_splice() Removes and replaces specified elements of an array 4
array_sum() Returns the sum of the values in an array 4
array_udiff() Compares array values in a user-made function and returns an array 5
array_udiff_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 5
array_udiff_uassoc() Compares array keys and array values in user-made functions, and returns an array 5
array_uintersect() Compares array values in a user-made function and returns an array 5
array_uintersect_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 5
array_uintersect_uassoc() Compares array keys and array values in user-made functions, and returns an array 5
array_unique() Removes duplicate values from an array 4
array_unshift() Adds one or more elements to the beginning of an array 4
array_values() Returns all the values of an array 4
array_walk() Applies a user function to every member of an array 3
array_walk_recursive() Applies a user function recursively to every member of an array 5
arsort() Sorts an array in reverse order and maintain index association 3
asort() Sorts an array and maintain index association 3
compact() Create array containing variables and their values 4
count() Counts elements in an array, or properties in an object 3
current() Returns the current element in an array 3
each() Returns the current key and value pair from an array 3
end() Sets the internal pointer of an array to its last element 3
extract() Imports variables into the current symbol table from an array 3
in_array() Checks if a specified value exists in an array 4
key() Fetches a key from an array 3
krsort() Sorts an array by key in reverse order 3
ksort() Sorts an array by key 3
list() Assigns variables as if they were an array 3
natcasesort() Sorts an array using a case insensitive "natural order" algorithm 4
natsort() Sorts an array using a "natural order" algorithm 4
next() Advance the internal array pointer of an array 3
pos() Alias of current() 3
prev() Rewinds the internal array pointer 3
range() Creates an array containing a range of elements 3
reset() Sets the internal pointer of an array to its first element 3
rsort() Sorts an array in reverse order 3
shuffle() Shuffles an array 3
sizeof() Alias of count() 3
sort() Sorts an array 3
uasort() Sorts an array with a user-defined function and maintain index association 3
uksort() Sorts an array by keys using a user-defined function 3
usort() Sorts an array by values using a user-defined function 3


PHP Array Constants

PHP: indicates the earliest version of PHP that supports the constant.

Constant Description PHP
CASE_LOWER Used with array_change_key_case() to convert array keys to lower case
CASE_UPPER Used with array_change_key_case() to convert array keys to upper case
SORT_ASC Used with array_multisort() to sort in ascending order
SORT_DESC Used with array_multisort() to sort in descending order
SORT_REGULAR Used to compare items normally
SORT_NUMERIC Used to compare items numerically
SORT_STRING Used to compare items as strings
SORT_LOCALE_STRING Used to compare items as strings, based on the current locale 4
COUNT_NORMAL
COUNT_RECURSIVE
EXTR_OVERWRITE
EXTR_SKIP
EXTR_PREFIX_SAME
EXTR_PREFIX_ALL
EXTR_PREFIX_INVALID
EXTR_PREFIX_IF_EXISTS
EXTR_IF_EXISTS
EXTR_REFS

15 Ağustos 2010 Pazar

Ajax control toolkit nedir, nasil kurulur,ne ise yarar

Ajax control toolkit ile gelen bir sürü kontrolün visual studio çalışma ortamına nasıl eklendiğine hep beraber bakalım.

Günümüzde web platformu yeni bir dönemece girmiş, bir çok yeni teknoloji ile web programcıların sıkıntıları bir nebze olsun azalmıştır. Platformlar web ortamını ne kadar masaüstüne yaklaştırırsa o kadar rağbet görürler. Yeni nesil web uygulamaları dediğimiz zaman direk akla gelen isimdir Ajax. Programcıların sorunlarını çözdüğü noktalar, getirdiği yenilikter tartışılamaz. Lafı fazla uzatmadan toolkitten bahsetmek istiyorum. Bir dizi bizim için hazırlanmış ajax kontrolleri bu paketle birlikte visual studio'ya entegre oluyor ve nasıl bir textbox'ımızı butonunumuzu sürükleyio bırakarak kullanabiliyorsak, bu toolkit ile gelen kontrolleri de aynı şekilde kullanabiliyoruz. Peki nasıl kuracağız?

Öncelikle visual studio 2008 ve 2008'in service pack 1 paketi kurulu olması gerekir. Yani bu toolkit .net 3.5 sp1 için diyebiliriz. Adım adım bakacak olursak

1-Ajax Control Toolkiti download ediyoruz.

AJAX CONTROL TOOLKIT
burada 3 seçeneğimiz var, istersek tam kurulum olarak alabiliriz, istersek sadece dll'leri, istersek sadece scriptlerinide alabiliriz. Biz dll'lerini alacağız ve projemiz referans olarak ekleyeceğiz.

2-Zipli dosyadan AjaxControlToolkitBinary adlı klasörü çıkarıyoruz.

3-Visual Studio 2008'imizi açıyoruz.

4-Yeni bir Web Application oluşturuyoruz.

5-Toolbox'ımızda yeni bir sekme oluşturuyoruz ve istediğimiz bir isim veriyoruz.

Bu adım isteğe bağlı, ama yapmanızı tavsiye ederim. Çünkü yaklaşık 40 tane yeni kontrol geliyor ve bunların hepsinin bir yerde durması erişebilirlik açısından daha mantıklı olacaktır.

http://resim.sanalkurs.net/uploads/image_thumb_5.jpg


6-Oluşturduğumuz sekmede sağ tuşa basıyoruz ve choose items diyoruz.

Karşımıza çıkan menüden browse diyerek download ettiğimiz klasörün içinde çıkan AjaxControlToolkit.dll isimli dll dosyasını ekliyoruz.

http://resim.sanalkurs.net/uploads/image_thumb_2.jpg

7-Ajax ile yapılmış 42 tane yeni kontrol göreceksiniz.

Artık kontrollerimizi web sayfamıza sürükleyip bırakarak kullanabiliriz. Toolkit ile ilgili yenilikleri, değişiklikleri, gelişmeleri buradaki adresten takip edebilirsiniz.

http://resim.sanalkurs.net/uploads/image_thumb_6.jpg

Henüz 2008'e geçmediyseniz .net 2.0 içinde bir toolkit mevcut. Ama Ajax 3.0 ile birlikte geldiği için 2.0'a elinizle önce Ajax'ı eklemeniz gerekiyor. Sonra da Ajax Control Toolkit'i.

1 Ağustos 2010 Pazar

Mysql Veritabanına Giriş Yapıyoruz

PHP , esnek bir web yazılım dilidir . Günümüzün gelişmiş birçok yazılım dilleri gibi birden fazla veritabanı (database) ile uyumlu halde çalışabilmektedir . Türkiye şartlarında düşünürsek , yazılım sektöründe PHP ile akla gelen ilk veritabanı MySQL olduğu için , ayrıca ORACLE , SQL ve diğerlerine nazaran PHP ile daha kullanışlı görünen veritabanı olduğu için , MYSQL derslerini yayınlamayı uygun buldum. MySQL genellikle PHP ile birlikte kullanılan ücretsiz bir veritabanı sunucusudur.

MySQL Nedir?

MySQL bir veritabanıdır.Veritabanı , bilgileri saklayan yapıları tanımlar.

Bir veritabanında , HTML tabloları gibi satır, sütun içeren tablolar bulunur.

Veritabanı , kategorilere göre veri saklamak için en uygun sistemdir. Bir şirketin örnek bir veritabanında “Müşteri” , “Ürün” , “Çalışanlar” ve “Sipariş” tabloları bulunur.
Veritabanı TablolarıOrtalama bir veritabanı genellikle bir veya birden fazla tablo içerir.Her tablo (“müşteri” veya “Sipariş” gibi) isimlendirilir. Her tablo veri kayıtlarını saklar.Aşağıda “insanlar” adında örnek bir tablo yaptık, inceleyelim :
Soyisim isim adres Şehir
Veli Uyanık Çankaya 10/2 Ankara
Cengiz Hayıf Cebeci 10/23 Ankara
Galip Bölük Strrazburg 20 Ankara
Sorgular

Sorgu, bir soru veya istek anlamındadır.

MySQL kayıtlarında , veritabanına yaptığımız sorgularda özel bilgileri, bir kayıtlı tablo kümesine sorgu yapabiliriz.

Aşağıdaki sorguya bakalım:

SELECT Soyisim FROM insanlar

Bu sorgu insanlar tablosunudaki Soyisim satırını bulur ve kayıtlı verileri döndürür:
Soyisim
Veli
Cengiz
Galip

MySQL Veritabanı İndirin

MySQL veritabanı sunucunuz PHP ile birlikte yüklememişse , ki PHP Kurulum yazımda kullanabileceğiniz PHP Web sunucuları hakkında detaylı bilgiler bulunur , aşağıdaki linkte , MySQL resmi web sitesinden veritabanınızı indirin: http://www.mysql.com/downloads/index.html

27 Temmuz 2010 Salı

Php ile Jquery Kullanımı

merhaba arkadaşlar epey zamandır sizlerden ayrı kaldım. Bu sürede php' ye olan ilgimden bir şey eksilmedi hatta ilgim arttı diyebilirim. Bundan sonraki yazı dizilerimde php ile Jquery kütüphanesini sizlere anlatmaya çalışacağım. Umarım işşinize yarar bilgiler sunabilirim. Görüşmek üzere.

20 Temmuz 2010 Salı

Php'de MD5 Fonksiyonu

Değiştirgeler

dizge

Özeti hesaplanacak dizge.

ham_çıktı

İsteğe bağlı bu değiştirgede TRUE belirtirseniz MD5 özeti 16 bayt uzunlukta ham ikil biçemli bir dizge olarak döner. FALSE öntanımlıdır.




$str
= 'apple';

if (
md5($str) === '1f3870be274f6c49b3e31a0c6728957f') {
echo
"Would you like a green or red apple?";
}
?>

17 Temmuz 2010 Cumartesi

php de diziler ve döngüler

Giriş

Bu var yazının son bölümlerinde nasıl metin ve değişkenler PHP ile başa çıkmak için size gösterdi ve nasıl ifadeler IF kullanabilirsiniz bunları karşılaştırmak ve kararlar almak.Nasıl PHP, döngüler bir başka önemli bölümünü kullanmak için size göstermek için gidiyorum bu bölümde.

The WHILE Loop WHILE Loop

WHILE döngü bir PHP en yararlı komutlar biridir. Aynı zamanda oldukça kurulumu kolaydır ve kullanmaktır. WHILE döngüsü, isminden de anlaşılacağı gibi, belirli bir koşul kadar karşılanmaktadır bir kod parçası yürütülür.

Repeating A Set Number Of Times Times Set Number Of A Yinelenen

If you have a piece of code which you want to repeat several times without retyping it, you can use a while loop. Onu yeniden yazmanız olmadan birkaç kez tekrarlamak istiyorum kod bir parça varsa, bir süre döngü kullanabilirsiniz. For instance if you wanted to print out the words "Hello World" 5 times you could use the following code: Örneğin size "Merhaba Dünya" 5 kat aşağıdaki kodu kullanabilirsiniz kelimeleri yazdırmak istiyorsa için:

$times = 5; $ Zaman = 5;
$x = 0; $ X = 0;
while ($x < $times) { ($ Times) <$ x while (
echo "Hello World"; echo "Merhaba Dünya";
++$x; + + $ X;
} )

I will now explain this code. Şimdi bu kodu açıklayacağız. The first two lines are just setting the variables. İlk iki satır sadece değişkenler ayarı vardır. The $times variable holds the number of times you want to repeat the code. $ Kere değişken kez kodu tekrar istediğiniz numarayı tutar. The $x variable is the one which will count the number of times the code has been executed. $ X değişkeni kez kod yürütülmesinden sayısını olacak olanıdır. After these is the WHILE line. Bu WHILE satır sonra. This tells the computer to repeat the code while $i is less than $times (or to repeat it until $i is equal to $times). $ I dolardan az kez (ya da bunu tekrarlayan kadar $ i $ eşit kat iken bu kod tekrarlamak için) bilgisayar söyler. This is followed by the code to be executed which is enclosed in { }. Bu kod tarafından hangi çalıştırılması gereken içine alınır izliyor ().

After the echo line which prints out the text, there is another very important line: metin yazdırır satır echo sonra, bir başka çok önemli satır:

++$x; + + $ X;

What this does is exactly the same as writing: Bu ne yapar tam olarak yazma aynıdır:

$x = $x + 1; $ X = $ x + 1;

It adds one to the value of $x. Dolar x. değerini bir ekler This code is then repeated (as $x now equals 1). Bu kod (as $ x şimdi 1 eşittir) tekrarlanır. It continues being repeated until $x equals 5 (the value of times) when the computer will then move on to the next part of the code. Bu x kadar $ tekrarlanma devam eşittir 5 (kez değer) Bilgisayar ardından kod sonraki bölüm için hareket edecek.

Using $x $ Kullanma x

The variable counting the number of repeats ($x in the above example) can be used for much more than just counting. Değişken tekrarlar ($ x yukarıdaki örnekte olduğu gibi) sayısını sayma için sadece sayım çok daha fazla kullanılabilir. For example if you wanted to create a web page with all the numbers from 1 to 1000 on it, you could either type out every single one or you could use the following code: Örneğin her tek bir veya aşağıdaki kodu kullanabilirsiniz, olabilirsin ya tip dışarı üzerine 1000-1 tüm numaraları ile bir web sayfası oluşturmak istiyorlarsa için:

$number = 1000; $ Sayısı = 1000;
$current = 0; $ Akım = 0;
while ($current < $number) { ($ While ($ cari
++$current; + + $ Akım;
echo "$current
";
echo "$ cari
";

} )

There are a few things to notice about this code. Bir kaç şey bu kodu ilgili fark vardır. Firstly, you will notice that I have placed the ++$current; before the echo statement. Öncelikle, ben + + $ güncel yerleştirilir farkedeceksiniz; beyanı yankı önce. This is because, if I didn't do this it would start printing numbers from 0, which is not what we want. Bu da 0 dan, bu bizim istediğimiz değil baskı sayıları başlayacak yapmadı eğer olmasıdır. The ++$current; line can be placed anywhere in your WHILE loop, it does not matter. + + $ Akım; satırı her yerde WHILE döngüsü içinde yer olabilir, hiç önemli değil. It can, of course, add, subtract, multiply, divide or do anthing else to the number as well. Tabii, ekleyebilir, çıkarma, çarpma veya bölme başka numaraya de olsaydın yok.

The other reason for this is that, if the ++$current; line was after the echo line, the loop would also stop when the number showed 999 because it would check $current which would equal 1000 (set in the last loop) and would stop, even though 1000 had not yet been printed. bu için diğer nedeni de, + + $ akım; satır satır echo sonra döngü de dolar olan 1000 (son döngü set eşit olacaktır geçerli onay çünkü zaman sayı 999 gösterdi durur olsaydı) ve rağmen, 1000 henüz basılmış olmamıştı tutardım.

Arrays Diziler

Arrays are common to many programing languages. Diziler çok programlama dilleri yaygındır. They are special variables which can hold more than one value, each stored in its own numbered 'space' in the array. Onlar bir değer, kendi içinde her depolanan fazla tutabilir özel değişkenlerdir 'dizisinde yer sayılı. Arrays are extremely useful, especially when using WHILE loops. Diziler son derece yararlı, özellikle WHILE döngüleri kullanıyor.

Setting Up An Array Dizi bir Ayarlama

Setting up an array is slightly different to setting up a normal variable. Normal bir değişken kurmanın bir dizi ayarlama biraz farklıdır. In this example I will set up an array with 5 names in it: Bu örnekte ben de 5 isimlerle bir dizi kuracak:

$names[0] = 'John'; $ Isim [0] = 'John';
$names[1] = 'Paul'; $ Isim [1] = 'Paul';
$names[2] = 'Steven'; $ Isim [2] = 'Steven';
$names[3] = 'George'; $ Isim [3] = 'George';
$names[4] = 'David'; $ Isim [4] = 'David';

As you can see, the parts of an array are all numbered, starting from 0. Gördüğünüz gibi, bir dizi bölümleri hepsi, 0 dan başlayarak numaralandırılır. To add a value to an array you must specify the location in the array by putting a number in [ ]. bir dizi size [] bir numara koyarak dizideki yerini belirlemeniz gerekir değerini ekleyin.

Reading From An Array Dizi An Okuma Gönderen

Reading from an array is just the same as putting information in. All you have to do is to refer to the array and the number of the piece of data in the array. bir diziden Okuma sadece yapmanız gereken tüm içeri bilgi koyarak aynı diziye ve dizi veri parçası sayısına bakın muhtemeldir. So if I wanted to print out the third name I could use the code: Ben de kodu kullanabilirsiniz üçüncü adını yazdırmak istedim:

n n
echo "The third name is $names[2]"; echo "üçüncü adı" $ isim [2];

Which would output: Hangi şekilde görüntülenir:

The third name is Steven Üçüncü isim Steven olduğunu

Using Arrays And Loops Döngüler kullanarak Diziler Ve

One of the best uses of a loop is to output the information in an array. Bir bir döngünün en iyi kullanan çıkış bilgileri bir dizi olduğunu. For instance if I wanted to print out the following list of names: Örneğin ben isimleri aşağıdaki listede çıktısını istiyorlarsa için:

Name 1 is John Adı 1 John
Name 2 is Paul Adı 2 Paul
Name 3 is Steven Adı 3 Steven olduğunu
Name 4 is George Adı 4 George
Name 5 is David Adı 5 David

I could use the following code: Ben aşağıdaki kodu kullanabilirsiniz:

$number = 5; $ Sayı = 5;
$x = 0; $ X = 0;
while ($x < $number) { ($ Sayı)
$namenumber = $x + 1; $ Namenumber = $ x + 1;
echo "Name $namenumber is $names[$x]
";
namenumber "Adı echo $" dır $
] isimleri $ x [;

++$x; + + $ X;
} )

As you can see, I can use the variable $x from my loop to print out the names in the array. Gördüğünüz gibi, ben x benim döngü dan dizideki isimlerini yazdırmak için değişken $ kullanabilirsiniz. You may have noticed I am also using the variable $namenumber which is always 1 greater than $x. Sen de her zaman 1 YTL'den büyük x. olduğu namenumber değişken $ kullanıyorum fark olabilir This is because the array numbering starts from 0, so to number the names correctly in the output I must add one to the actual value. dizi 0 dan, sayı çok doğru çıktı ben gerçek değeri bir eklemelisiniz isimleri başlar numaralandırma olmasıdır.

Part 5 Bölüm 5

In the next part I will show you how you can send e-mail using PHP. Gönderdiğiniz nasıl sonraki bölümde Ben e-mail PHP kullanarak gösterecektir.