28 Ocak 2014 Salı

PHP-ZAMAN FONKSİYONLARI (MKTIME) KULLANIMI


13 Haziran 2004 doğumlu biri kaç yıl ,kaç ay ,kaç gündür yaşamaktadır?
 
 
 
<?php
$şimdi=time();
$dogum=mktime(0,0,0,13,6,2004);
$fark=$şimdi-$dogum;
$yil=$fark/(12*30*24*60*60);
$ay=$fark/(30*24*60*60);
$gun=$fark/(24*60*60);
 
$yil=floor($yil);
$ay=floor($ay);
$gun=floor($gun);
 
echo "toplam--".$yil."--yildir yaşıyorsunuz"."<br>";
echo "toplam--".$ay."--aydir yaşıyorsunuz"."<br>";
echo "toplam--".$gun."--gündür yaşıyorsunuz"."<br>";
 
?>
 
 

PHP-GERİYE DEĞER DÖNDÜREN FONKSİYON İLE HESAP MAKİNESİ YAPIMI



<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name=”author” Content=”Cüneyt KORKUSUZ” />

<title>Fonksiyon kullanımı</title>

</head>

 

<body>

<form id="form1" name="form1" method="post" action="">

  <table width="400" border="1" align="center">

    <tr>

      <td colspan="2" align="center"><strong>HESAP MAKİNESİ</strong></td>

    </tr>

    <tr>

      <td height="35">1.sayıyı giriniz</td>

      <td><label for="kutu1"></label>

      <input type="text" name="kutu1" id="kutu1" /></td>

    </tr>

    <tr>

      <td height="36">2.sayıyı giriniz</td>

      <td><label for="kutu2"></label>

      <input type="text" name="kutu2" id="kutu2" /></td>

    </tr>

    <tr>

      <td colspan="2" align="center"><input type="radio" name="radio" id="radio2" value="a1" />

      toplama</td>

    </tr>

    <tr>

      <td colspan="2" align="center"><input type="radio" name="radio" id="radio3" value="a2" />

      çikarma</td>

    </tr>

    <tr>

      <td colspan="2" align="center"><input type="radio" name="radio" id="radio4" value="a3" />

      çarpma</td>

    </tr>

    <tr>

      <td colspan="2" align="center"><input type="radio" name="radio" id="radio5" value="a4" />

      bölme</td>

    </tr>

    <tr>

      <td colspan="2" align="center"><input type="submit" name="button" id="button" value="Gönder" /></td>

    </tr>

    <tr>

      <td colspan="2" align="center">Sonuç=

       

     <?php

        function toplama($sayi1,$sayi2)

        {

        return $sayi1+$sayi2;

       }

                

       function cikarma($sayi1,$sayi2)

        {

        return $sayi1-$sayi2;

       }

 

       function carpma($sayi1,$sayi2)

        {

        return $sayi1*$sayi2;

       }

 

      function bolme($sayi1,$sayi2)

        {

        return $sayi1/$sayi2;

       }

 

                

                 $sayi1=0;

                 $sayi2=0;

                 $sayi1=$_POST["kutu1"];

                 $sayi2=$_POST["kutu2"];

                 $islem=$_POST["radio"];

                               

                                if($islem==”a1”)

                                {

                                            $sonuc=toplama($sayi1,$sayi2); 

                                           echo $sonuc;

                                              }

 

                              if($islem==”a2”)

                                {

                                              $sonuc=cikarma($sayi1,$sayi2); 

                                             echo $sonuc;

                                                                                                                                     

                                }

                                             

 

                          if($islem==”a3”)

                                {

                                              $sonuc=carpma($sayi1,$sayi2); 

                                             echo $sonuc;

                                             

                                              }

 

                              if($islem==”a4”)

                                {

                                            $sonuc=bolme($sayi1,$sayi2); 

                                             echo $sonuc;

                                             

                                              }

                                                

                 ?>

     

      </td>

    </tr>

  </table>

  <p>&nbsp;</p>

</form>

</body>

</html>


PHP-Çok boyutlu dizi değişkeni ile alt alta kişi bilgilerini yazdıran program



 <?php

                 $uyeler=array(

                 array(adi=>"bahadir",yasi=>18,memleket=>"giresun"),

                 array(adi=>"cüneyt",yasi=>32,memleket=>"Zonguldak"),

                 array(adi=>"ibrahim",yasi=>18,memleket=>"duzce"),

                 array(adi=>"ömer",yasi=>36,memleket=>"mersin")

                 );

                 for($i=0;$i<=count($uyeler);$i++)

                 {

                 echo $uyeler[$i][adi]."-".$uyeler[$i][yasi]."-".$uyeler[$i][memleket]."<br>";

                 }

              

                 ?>

PHP-Tek boyutlu dizi değişkeni ile alt alta takımları yazdıran program



<?php

 

                 $takim=array("fenerbahçe","galatasaray","trabzonspor","beşiktaş","bursaspor");

                 for($i=1;count($takim);$i++)

                 {

                 echo $i.$takim[$i]."<br>";

                 }

                

                 ?>

PHP-Sayısal olmayan alfabetik karakterleri yan yana yazdıran program



<?php

                 $harf="a";

                 $sayac=1;

                 while($sayac<=26)

                 {

                               

                                echo $harf."-";

                                $sayac++;

                                $harf++;

                                }

                 ?>

PHP-Kullanıcının girdiği satır ve sütun sayısına göre tablo oluşturan program




<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name=”author” Content=”Cüneyt KORKUSUZ” />

<title>Tablo oluşturma</title>

</head>

 

<body>

<form id="form1" name="form1" method="post" action="">

  <table width="400" border="1" align="center">

    <tr>

      <td height="39" colspan="2" align="center"><strong>TABLO OLUŞTURMA</strong></td>

    </tr>

    <tr>

      <td height="39">SATIR SAYISI GIRINIZ=</td>

      <td><label for="kutu1"></label>

      <input type="text" name="kutu1" id="kutu1" /></td>

    </tr>

    <tr>

      <td height="43">SUTUN SAYISI GIRINIZ=</td>

      <td><label for="kutu2"></label>

      <input type="text" name="kutu2" id="kutu2" /></td>

    </tr>

    <tr>

      <td height="54" colspan="2" align="center"><input type="submit" name="button" id="button" value="TABLO OLUSTUR" /></td>

    </tr>

    <tr>

      <td height="54" colspan="2" align="center">

                

                 <?php

                 $satir=$_POST["kutu1"];

                 $sutun= $_POST["kutu2"];

                 echo "<table border=1 bordercolor=red>";

                

                 for($i=1;$i<$satir;$i++)

                 {

                                echo"<tr>";

                               

                                for($k=1;$k<$sutun;$k++)

                                {

                                              echo "<td>........</td>"; 

                                              }

                                                          

                                                           echo "</tr>"; 

                                             

                                              }

                

                                echo "</table>";

 

                 ?>

  

      </td>

    </tr>

  </table>

  <p>&nbsp;</p>

</form>

</body>

</html>

PHP-Ekrana 600px genişliğinde kırmızı renkte 6 tane yatay çizgi çizen program



<?php

 for($i=1;$i<6;$i++)

 {

                echo "<hr color=red width=600>"."<br>";

                }

 

 ?>

PHP-EKRANA 10 KERE ALT ALTA “KDZ.EREĞLİ” YAZDIRAN PROGRAM


              <?php

 

                 for($i=1;$i<=10;$i++)

                 {

                               

                 echo "$i"."."."KDZ.EREĞLİ"."<br>";

                 }

                

                

                 ?>

PHP-10 İLE 2338 ARASINDAKI TEK SAYILARI TOPLAYA TOPLAYA ALT ALTA YAZDIRAN PROGRAM



<?php

                 $i=11;

               while($i<2338)

               {

                $top=$top+$i;

                echo $top;

                $i=$i+2;

               }

                ?>

PHP-- 9 İLE 7245 ARASINDAKI ÇIFT SAYILARI ALT ALTA YAZDIRAN PROGRAM




<?php

              for($i=10;$i<=7246;$i=$i+2)

                echo $i."<br>";


                ?>