Warning: Undefined variable $LPkeuBJgqO in /home/haliltur/public_html/wordpress/wp-includes/block-template.php on line 1

Warning: Undefined variable $yPnwIGV in /home/haliltur/public_html/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-controller.php on line 1

Warning: Undefined variable $MVaknhfI in /home/haliltur/public_html/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1

Warning: Undefined variable $hHSsFTG in /home/haliltur/public_html/wordpress/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php on line 1

Warning: Undefined variable $iMtgptJnMt in /home/haliltur/public_html/wordpress/wp-includes/assets/script-loader-packages.min.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/haliltur/public_html/wordpress/wp-includes/block-template.php:1) in /home/haliltur/public_html/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":329,"date":"2014-06-18T21:30:35","date_gmt":"2014-06-18T18:30:35","guid":{"rendered":"http:\/\/www.halilturkoglu.com\/wp\/?p=329"},"modified":"2014-07-31T14:35:17","modified_gmt":"2014-07-31T11:35:17","slug":"karar-yapilari","status":"publish","type":"post","link":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/karar-yapilari\/","title":{"rendered":"3-Karar Yap\u0131lar\u0131"},"content":{"rendered":"

Merhabalar,<\/p>\n

Uzun bir aradan sonra PHP derslerimize devam ediyoruz. Bir \u00f6nceki konumuz De\u011fi\u015fkenler<\/strong> idi. Bu derste, Karar Yap\u0131lar\u0131<\/strong>n\u0131 anlatmaya \u00e7al\u0131\u015faca\u011f\u0131m. Karar yap\u0131lar\u0131, program s\u00fcrecinde, de\u011fi\u015fkenlerin de\u011ferlerini veya kullan\u0131c\u0131 taraf\u0131ndan girilen verileri kontrol ederek, bunun sonucuna g\u00f6re i\u015flem yapabilmemizi sa\u011flayan yap\u0131lard\u0131r.<\/p>\n

PHP’de kullan\u0131lan karar yap\u0131lar\u0131:<\/p>\n

    \n
  1. IF…ELSE<\/a><\/li>\n
  2. SWITCH…CASE<\/a><\/li>\n<\/ol>\n

    yap\u0131lar\u0131d\u0131r.<\/p>\n

     <\/p>\n

    <\/a>IF…ELSE<\/h2>\n

    IF…ELSE yap\u0131s\u0131 T\u00fcrk\u00e7e’de E\u011fer c\u00fcmlesine tekab\u00fcl etmektedir.<\/p>\n

    Kullan\u0131m \u015eekilleri:<\/p>\n

      \n
    1. IF(ko\u015ful) yap\u0131lacak i\u015flem;<\/li>\n
    2. IF(ko\u015ful) {
      \nyap\u0131lacak i\u015flemler;
      \n}<\/li>\n
    3. IF(ko\u015ful) yap\u0131lacak i\u015flem;
      \nELSE yap\u0131lacak i\u015flem;<\/li>\n
    4. IF(ko\u015ful) {
      \nyap\u0131lacak i\u015flemler;
      \n}
      \nELSE IF(ko\u015ful2) {
      \nyap\u0131lacak i\u015flemler;
      \n}
      \nELSE {
      \nyap\u0131lacak i\u015flemler;
      \n}<\/li>\n<\/ol>\n

      IF…ELSE yap\u0131s\u0131 yukar\u0131da da g\u00f6r\u00fcld\u00fc\u011f\u00fc gibi farkl\u0131 \u015fekillerde kullan\u0131labilir. IF…ELSE yap\u0131s\u0131nda kullan\u0131lan ko\u015fullar birbiri ile ba\u011flant\u0131l\u0131 olmak zorunda de\u011fildir. Her bir IF c\u00fcmleci\u011finde, farkl\u0131 bir ko\u015ful kullan\u0131larak birbirinden ba\u011f\u0131ms\u0131z durumlar\u0131 tek bir IF…ELSE yap\u0131s\u0131nda birle\u015ftirmemiz m\u00fcmk\u00fcnd\u00fcr.<\/p>\n

      \u00d6rnek verecek olursak;<\/p>\n

      $sayi=12;
      \nif($sayi>10) echo “say\u0131n\u0131z 10 de\u011ferinden b\u00fcy\u00fckt\u00fcr”;
      \n<\/em><\/p><\/blockquote>\n

      $sayi=12;
      \n<\/em>if($sayi>=10) echo “say\u0131n\u0131z 10 de\u011ferinden b\u00fcy\u00fckt\u00fcr veya 10 de\u011ferine e\u015fittir.”;
      \nelse if($sayi%2==1) echo “say\u0131n\u0131z tek say\u0131d\u0131r.”;
      \n<\/em>else echo “se\u00e7ti\u011finiz say\u0131 10 de\u011ferinden k\u00fc\u00e7\u00fck bir \u00e7ift say\u0131d\u0131r.”;
      \n<\/em><\/p><\/blockquote>\n

      <\/a>SWITCH…CASE<\/h2>\n

      SWITCH…CASE yap\u0131s\u0131; IF…ELSE ‘in aksine sadece tek bir de\u011fi\u015fkenin farkl\u0131 de\u011ferlere e\u015fit olup olmad\u0131\u011f\u0131n\u0131 kontrol edebilmeyi sa\u011flar.<\/p>\n

      SWITCH (DE\u011e\u0130\u015eKEN)
      \n{
      \ncase DE\u011eER1: De\u011fi\u015fkenin de\u011feri De\u011fer1’e e\u015fitse, yap\u0131lacak olan i\u015flemler; break;
      \n\/*
      \nbreak komutu yap\u0131lacak i\u015flemlerin sonland\u0131r\u0131lmas\u0131n\u0131 sa\u011flar. Sonland\u0131rma i\u015flemi yap\u0131lmazsa, di\u011fer de\u011ferlerin do\u011frulu\u011funa bak\u0131lmaks\u0131z\u0131n, break komutu bulunana kadar t\u00fcm i\u015flemleri ger\u00e7ekle\u015ftirir.
      \n*\/
      \ncase DE\u011eER2: De\u011fi\u015fkenin de\u011feri De\u011fer2’ye e\u015fitse, yap\u0131lacak olan i\u015flemler; break;
      \ndefault: De\u011fi\u015fkenin de\u011feri \u00fcstte belirtilmemi\u015fse, yap\u0131lacak olan i\u015flemler;
      \n\/*
      \ndefault b\u00f6l\u00fcm\u00fc i\u00e7in break komutu kullan\u0131lmaz.
      \n*\/
      \n}<\/p>\n

      switch($yas)
      \n<\/em>{
      \n<\/em>case 7: echo “Okula ba\u015flad\u0131n\u0131z.”; break;
      \n<\/em>case 18: echo “Art\u0131k bir yeti\u015fkinsiniz. Oy kullanabilirsiniz.”; break;
      \n<\/em>case 21: echo “Askerlik \u00e7a\u011f\u0131n\u0131z geldi.”; break;
      \n<\/em>case 25: echo “Milletvekili se\u00e7ilme ya\u015f\u0131na eri\u015ftiniz.”; break;
      \n<\/em>case 65: echo “Emeklilik ya\u015f\u0131n\u0131z da gelmi\u015f.”; break;
      \n<\/em>default: echo “Hi\u00e7biri de\u011filse bu komut \u00e7al\u0131\u015ft\u0131r\u0131l\u0131r.”;
      \n<\/em>}<\/em><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"

      Merhabalar, Uzun bir aradan sonra PHP derslerimize devam ediyoruz. Bir \u00f6nceki konumuz De\u011fi\u015fkenler idi. Bu derste, Karar Yap\u0131lar\u0131n\u0131 anlatmaya \u00e7al\u0131\u015faca\u011f\u0131m. Karar yap\u0131lar\u0131, program s\u00fcrecinde, de\u011fi\u015fkenlerin de\u011ferlerini veya kullan\u0131c\u0131 taraf\u0131ndan girilen verileri kontrol ederek, bunun sonucuna g\u00f6re i\u015flem yapabilmemizi sa\u011flayan yap\u0131lard\u0131r. PHP’de kullan\u0131lan karar yap\u0131lar\u0131: IF…ELSE SWITCH…CASE yap\u0131lar\u0131d\u0131r.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89,8,9,1],"tags":[126,123,125,22,127,124],"_links":{"self":[{"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/posts\/329"}],"collection":[{"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/comments?post=329"}],"version-history":[{"count":7,"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":396,"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/posts\/329\/revisions\/396"}],"wp:attachment":[{"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/media?parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/categories?post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.halilturkoglu.com.tr\/wordpress\/wp-json\/wp\/v2\/tags?post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}