{"id":294,"date":"2017-12-27T19:11:11","date_gmt":"2017-12-27T17:11:11","guid":{"rendered":"http:\/\/blog.okanacar.com.tr\/?p=294"},"modified":"2021-01-16T22:40:31","modified_gmt":"2021-01-16T19:40:31","slug":"yapay-parametreler-arguman","status":"publish","type":"post","link":"https:\/\/okanacar.com.tr\/blog\/?p=294","title":{"rendered":"Yapay Parametreler (Arg\u00fcman)"},"content":{"rendered":"\n<p>E\u011fer fonksiyon i\u00e7in g\u00f6nderilecek parametre say\u0131s\u0131nda bir bbelirsizlik varsa ya dizi y\u00f6ntemi ya da \u015fimdi bahsedece\u011fim y\u00f6ntemi tercih etmelisiniz. Bu y\u00f6ntem i\u00e7in 3 adet <a href=\"http:\/\/blog.okanacar.com.tr\/kategori\/php\/\">PHP<\/a>&nbsp;fonksiyonu \u00f6\u011frenece\u011fiz.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Prototip<\/th><th>Tan\u0131m<\/th><\/tr><tr><td>mixed&nbsp; &nbsp; &nbsp; func_get_arg ($int $n)<\/td><td>Fonksiyona g\u00f6nderilen arg\u00fcman dizisinden $n. indisi<br>d\u00f6nd\u00fcr\u00fcr. E\u011fer $n. indis bulamaz ise hata verir.<\/td><\/tr><tr><td>array&nbsp; &nbsp; &nbsp; &nbsp; func_get_args (void)<\/td><td>Fonksiyona g\u00f6nderilen arg\u00fcmanlar\u0131 dizi olarak<br>d\u00f6nd\u00fcr\u00fcr.<\/td><\/tr><tr><td>int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;func_num_args (void)<\/td><td>Fonksiyona g\u00f6nderilen arg\u00fcman say\u0131s\u0131n\u0131 d\u00f6nd\u00fcr\u00fcr.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code lang:php decode:true\"><code lang=\"php\" class=\"language-php\">&lt;?php \nfuncion argumanlar(){\n\t$adet = func_num_args();\n\t\tif($adet == 0)\n\t\treturn;\n\t\techo $adet . ' parametre bulundu.&lt;br&gt;';\n\tif($adet &gt; 1){\n\t\t$args = func_get_args();\n\t\tforeach ($args as $key){\n\t\t\techo $key . '&lt;br&gt;';\n\t\t}\n\t#echo func_get_arg(1) komutu ile 2. s\u0131radaki de\u011fer al\u0131nabilir.\n\t}else{\n\t\techo func_get_arg(0) . '&lt;br&gt;';\n\t}\n\techo '&lt;br&gt;';\n}\n\nargumanlar ();\nargumanlar ('HTML5');\nargumanlar ('PHP','MySQL');\n?&gt;<\/code><\/pre>\n\n\n\n<p>Yukar\u0131daki \u00f6rnekte, normalde fonksiyon herhangi bir parametre almamas\u0131na ra\u011fmen, parametre g\u00f6nderdi\u011fimizde bu parametrelere eri\u015febiliyoruz. \u00d6rnekte \u00f6ncelikle <em>func_num_args()<\/em> ile ka\u00e7 adet parametre alg\u0131land\u0131\u011f\u0131n\u0131 \u00f6\u011frendik.<br>E\u011fer hi\u00e7 parametre yoksa fonksiyondan \u00e7\u0131k\u0131yoruz. E\u011fer birden fazla parametre varsa t\u00fcm parametrelere eri\u015fmek i\u00e7in <em>func_get_args()<\/em> fonksiyonu ile t\u00fcm parametrelere tek sefer eri\u015febiliyoruz. E\u011fer tek parametre g\u00f6nderilmi\u015fse <em>func_get_arg()<\/em> metodu ile parametreyi al\u0131yoruz.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>E\u011fer fonksiyon i\u00e7in g\u00f6nderilecek parametre say\u0131s\u0131nda bir bbelirsizlik varsa ya dizi y\u00f6ntemi ya da \u015fimdi bahsedece\u011fim y\u00f6ntemi tercih etmelisiniz. Bu y\u00f6ntem i\u00e7in 3 adet PHP&nbsp;fonksiyonu \u00f6\u011frenece\u011fiz. PrototipTan\u0131mmixed&nbsp; &nbsp; &nbsp; func_get_arg ($int $n)Fonksiyona g\u00f6nderilen arg\u00fcman dizisinden $n. indisid\u00f6nd\u00fcr\u00fcr. E\u011fer $n. indis bulamaz ise hata verir.array&nbsp; &nbsp; &nbsp; &nbsp; func_get_args (void)Fonksiyona g\u00f6nderilen arg\u00fcmanlar\u0131 dizi olarakd\u00f6nd\u00fcr\u00fcr.int&nbsp; &nbsp; &nbsp; &hellip;<\/p>\n","protected":false},"author":1,"featured_media":314,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[71,16,70],"_links":{"self":[{"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/294"}],"collection":[{"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":7,"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":2361,"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions\/2361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=\/wp\/v2\/media\/314"}],"wp:attachment":[{"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/okanacar.com.tr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}