![]() |
|
|||||||
PHP örnekler ![]() |
|
|
LinkBack | Seçenekler | Stil |
|
|
#1 |
|
tarihi yazdırmak
Kod: <html> <head> <title>Example #1 TDavid's Very First PHP Script ever!</title> </head> <? print(Date("1 F d, Y")); ?> <body> </body> </html> HTML-Kodu: <html> <head> <title>Example #3 TDavid's Very First PHP Script ever!</title> </head> <? print(Date("m/j/y")); ?> <body> </body> </html> HTML-Kodu: <html> <head> <title>PHP Script examples!</title> </head> <font face="Arial" color="#FF00FF"><strong><? print(Date("m/j/y")); ?> </strong></font> <body> </body> </html> Kod: <html> <head> <title>Example #1 TDavid's Very First PHP Script ever!</title> </head> <? print(Date("l F d, Y")); ?> <body> </body> </html> |
|
|
|
|
|
|
#2 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
Haftanın her günü farklı arkaplan rengi
HTML-Kodu: <html> <head> <title>Background Colors change based on the day of the week</title> </head> <? $today = date("l"); print("$today"); if($today == "Sunday") { $bgcolor = "#FEF0C5"; } elseif($today == "Monday") { $bgcolor = "#FFFFFF"; } elseif($today == "Tuesday") { $bgcolor = "#FBFFC4"; } elseif($today == "Wednesday") { $bgcolor = "#FFE0DD"; } elseif($today == "Thursday") { $bgcolor = "#E6EDFF"; } elseif($today == "Friday") { $bgcolor = "#E9FFE6"; } else { // Since it is not any of the days above it must be Saturday $bgcolor = "#F0F4F1"; } print("<body bgcolor=\"$bgcolor\">\n"); ?> <br>This just changes the color of the screen based on the day of the week </body> </html> farklı bir yöntem ile HTML-Kodu: <html> <head> <title>Background Colors change based on the day of the week</title> </head> <? $today = date("w"); $bgcolor = array( "#FEF0C5", "#FFFFFF", "#FBFFC4", "#FFE0DD", "#E6EDFF", "#E9FFE6", "#F0F4F1" ); ?> <body bgcolor="<?print("$bgcolor[$today]");?>"> <br>This just changes the color of the screen based on the day of the week </body> </html> |
|
|
|
|
|
#3 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
sayfanın en son değiştirilme tarihini gösteren php kodu
HTML-Kodu: <html> <head> <title>Page last updated on month/date/year hour:min PHP Script</title> </head> <? $last_modified = filemtime("example7.php3"); print("Last Modified "); print(date("m/j/y h:i", $last_modified)); ?> </body> </html> |
|
|
|
|
|
#4 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
cookie örneği
Kod: <? $check = "test"; $check .= $filename; if ($test == $check) { print("<HTML><BODY>You have already voted. Thank you.</BODY></HTML>"); } else { $rated = "test"; $rated .= $filename; setcookie(test, $rated, time()+86400); print("<HTML><BODY><br>You haven't voted before so I recorded your vote</BODY></HTML>"); } ?> |
|
|
|
|
|
#5 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
basit bir oyun örneği
Kod: <? function slotnumber() { srand(time()); for ($i=0; $i < 3; $i++) { $random = (rand()%3); $slot[] = $random; } print("<td width=\"33%\"><center>$slot[0]</td>"); print("<td width=\"33%\"><center>$slot[1]</td>"); print("<td width=\"33%\"><center>$slot[2]</td>"); if($slot[0] == $slot[1] && $slot[0] == $slot[2]) { print("</td></tr>Winner! -- Hit refresh on your browser to play again"); exit; } } ?> <div align="center"><center> <table border="1" width="50%"> <tr> <? slotnumber(); ?> </td> </tr> <tr> <td width="100%" colspan="3" bgcolor="#008080"><form method="POST" action="example13.php3"><div align="center"><center><p><input type="submit" value="Spin!"></p> </center></div> </form> </td> </tr> </table> </center></div> |
|
|
|
|
|
#6 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
HTML-Kodu:
<? $random_url = array("http://www.tdscripts.com/linkorg.html", "http://www.tdscripts.com/keno.html", "http://www.tdscripts.com/ezibill.shtml", "http://www.tdscripts.com/tdforum.shtml", "http://www.tdscripts.com/picofday.html", "http://www.tdscripts.com/gutsorglory.html"); $url_title = array("Link Organizer", "TD Keno", "eziBill *Free Promotion!", "TD Forum", "TD Pic of Day PHP", "Guts or Glory Poker PHP"); $url_desc = array("- A comprehensive link list organizer", "- Offer your site visitors an engaging Keno game without the monetary risk", "- Sell access to and protect your membership area using iBill and our eziBill script", "- An unthreaded messageboard script to exchange ideas with your site visitors", "- Run your own picture of the day script from any site anywhere with this handy script", "- A casino-style card game written entirely in PHP"); srand(time()); $sizeof = count($random_url); $random = (rand()%$sizeof); print("<center><a href=\"$random_url[$random]\">$url_title[$random]</a> $url_desc[$random]</center>"); ?> |
|
|
|
|
|
#7 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
php ile mail gönderme örneği:
Kod: <? // force all uppercase print(strtoupper("i bet this will show up as all letters capitalized<br>")); // force all lowercase print(strtolower("I BET THIS WILL SHOW UP AS ALL LETTERS IN LOWERCASE<br>")); // force the first letter of a string to be capitalized print(ucfirst("i bet this will show the first letter of the string capitalized<br>")); // force the first letter of each WORD in a string to be capitalized print(ucwords("i bet this will show the first letter of every word capitalized<br>")); ?> string işlemleri büyük - küçük harfe çevirmek |
|
|
|
|
|
#8 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
Basit AdRotator
reklamlar.txt içinde [REKLAM] ile ayrılmış kodları rasgele olarak sayfada gösterir. PHP- Kodu: <? //---------------------------------------------------- // Basit Reklam Scripti / @ Yns : 18 $ubat 2006 18.00 //---------------------------------------------------- // Eger PHP versiyonu dusukse get_file_contents() fonksiyonunu tanimla // ---------------------------------------------------------------------- if(!function_exists("file_get_contents")) { $cikti = ''; function file_get_contents($dosya) { $islem = fopen($dosya, 'r'); while(!feof($islem)) { $cikti .= fread($islem,filesize($dosya)) ; } fclose($islem); return $cikti; } } // Dosya icerigini hafizaya al , uygun bicimde ayir ve rasgele ekrana bas // ---------------------------------------------------------------------- $kaynak_kodlar = file_get_contents("reklamlar.txt"); $reklamlar_dizisi = explode('[REKLAM]',$kaynak_kodlar); $rasgele = rand(0,(sizeof($reklamlar_dizisi)-1)); echo $reklamlar_dizisi[$rasgele]; // Son //---------------------------------------------------------------------- ?> |
|
|
|
|
|
#9 |
|
Tek Tabanca
![]() Üyelik tarihi: Jan 2010
Mesajlar: 1.036
Konular: 614
Thanks: 0
Thanked 0 Times in 0 Posts Rep Puanı:14
Rep Gücü:4
RD:
![]() |
MD5 İle Güvenli Şifreleme
MD5'i bilmeyen bir webmaster yoktur. Zaten bilmeyen webmaster değildir PHP'nin MD5 şifresi oluşturmak için kullandığı özel string fonksiyonu vardır. Onuda hemen aklınızda tutabilirsiniz... Örnek: PHP- Kodu: print MD5(oktayusx); Bu string'i php sayfamıza koyduğumuzda bize oktayusx karakterleri geçen şifrenin MD5'e çevrilmiş şeklini verecektir.. Eklediğimizi varsayalım ve sayfada çıkan yazı: Kod: bdc53a1cae8421981d1baeafb8cbf6c6 Evet oktayusx'in MD5'lenmiş hali buymuş =) Ama bir şeye dikkat edelim. Büyük küçük harf uyumluluğu =) Yani şifrenin büyük ve küçük harflerini doğru olarak string'e girmeniz gerekmektedir ... Biraz geliştirelim ... PHP- Kodu: $sifre= oktayusx;$guvenli_sifre= MD5($sifre);print $guvenli_sifre; |
|
|
|
![]() |
| Bookmarks |
| Etiketler |
| php, örnekler |
| Seçenekler | |
| Stil | |
|
|