<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flashcentury &#187; Case</title>
	<atom:link href="http://www.flashcentury.net/tag/case/feed" rel="self" type="application/rss+xml" />
	<link>http://www.flashcentury.net</link>
	<description>Flashcentury Web Design &#124; K78</description>
	<lastBuildDate>Wed, 28 Jul 2010 03:40:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Php ‘de Mantıksal İfadeler (Switch)</title>
		<link>http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html</link>
		<comments>http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html#comments</comments>
		<pubDate>Thu, 28 Jan 2010 18:15:03 +0000</pubDate>
		<dc:creator>Hüseyin Kocak</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Break]]></category>
		<category><![CDATA[Case]]></category>
		<category><![CDATA[çok seçenekli mantıksal sorgulama]]></category>
		<category><![CDATA[Default]]></category>
		<category><![CDATA[if Else]]></category>
		<category><![CDATA[Mantıksal İfadeler]]></category>
		<category><![CDATA[Mantiksal Operatörler]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Switch]]></category>

		<guid isPermaLink="false">http://www.flashcentury.net/?p=638</guid>
		<description><![CDATA[Bir önceki Php dersimizde if ve else ile mantıksal ifadeleri kullanmayı anlatmıştım, şimdi ise Php &#8216;de matiksal ifadelerin diğer bir alternatifi olan switch deyimini anlatacağım. Switch &#8216;in kullanım mantığı oldukca basittir. switch ( değişken ) { case Koşul; Koşul doğru ise yapılacak işlem break; case Koşul; Koşul doğru ise yapılacak işlem break; default: Hicbir kosul [...]]]></description>
			<content:encoded><![CDATA[<p>Bir önceki <a title="Php Dersleri" href="http://www.flashcentury.net/index.php/tag/php-dersleri" target="_self">Php </a>dersimizde <a title="Php de Mantıksal İfadeler (If Else)" href="http://www.flashcentury.net/index.php/php-dersleri/php-de-mantiksal-ifadeler-if-else.html" target="_self">if ve else ile mantıksal ifadeleri kullanmayı </a>anlatmıştım, şimdi ise <a title="Php" href="http://www.flashcentury.net/index.php/tag/php" target="_self">Php</a> &#8216;de <a title="Mantiksal ifade" href="http://www.flashcentury.net/index.php/tag/mantiksal-ifadeler" target="_self">matiksal ifadelerin </a>diğer bir alternatifi olan <a title="Switch" href="http://www.flashcentury.net/index.php/tag/switch" target="_self">switch</a> deyimini anlatacağım.</p>
<p>Switch &#8216;in kullanım mantığı oldukca basittir.</p>
<p class="MsoNormal"><span style="color: #003300;"><strong>switch (</strong> </span><strong><span style="color: #339966;">değişken</span><span style="color: #ff00ff;"><span style="color: #339966;"> </span><span style="color: #003300;">)<span id="more-638"></span></span></span><span style="color: #003300;"> </span><br />
<span style="color: #003300;">{</span></strong><br />
<span style="color: #0000ff;">case Koşul;<br />
</span><span style="mso-tab-count: 1;"> </span><span style="color: #ff0000;">Koşul doğru ise yapılacak işlem<br />
</span><span style="color: #0000ff;">break;<br />
</span><br />
<span style="color: #008000;"><span style="color: #0000ff;">case Koşul;</span><br />
</span><span style="mso-tab-count: 1;"> </span><span style="color: #ff0000;">Koşul doğru ise yapılacak işlem<br />
</span><span style="color: #0000ff;">break;</span></p>
<p><span style="color: #0000ff;">default:</span><br />
<span style="mso-tab-count: 1;"> </span><span style="color: #ff0000;">Hicbir kosul uymuyorsa yapilacak islem</span><br />
<span style="color: #003300;">}</span></p>
<p><strong>Switch -&gt;</strong> Ana kodumuz olan Switch değimi ile bir değişken çağırıyoruz ve Switch &#8216;in kapsadığı kodlarımızı parantez ( <strong><span style="color: #ff0000;">{ <span style="color: #000000;">ve</span> }</span></strong> ) içerisine alıyoruz.<br />
<strong>Case     -&gt;</strong> koşullarımızı case ile test ediyoruz ve eğer uygunsa aşağıda ki satirda yapilacak işlemleri belirtiyoruz.<br />
<strong>break   -&gt;</strong> Eğer koşulumuz dogru ise, yapılacak işlemler gerçekleştıkten sonra break parametresi ile switch kontrolunu durduruyoruz.<br />
<strong>default -&gt;</strong> Eğer hiç bir koşul uygun değılse default devreye giriyor. default &#8216;u if ile kosullandirmada else &#8216;ye benzetebiliriz.</p>
<p>Şimdi isterseniz bir önceki dersimizde vermiş olduğum örneği switch ile yapalim</p>
<pre class="brush: php;">
$Adiniz = &quot;Hüseyin&quot;;

switch ($Adiniz)
{
case &quot;Hüseyin&quot; :
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Merhaba Hüseyin&quot;;
break

case &quot;Sevgi&quot;:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Merhaba Sevgi&quot;;
break

default
echo &quot;Sizi Tanimiyorum&quot;;
}
</pre>
<p>Yukarıda da bahsettiğim gibi <a title="Swıtch" href="http://www.flashcentury.net/index.php/tag/switch">Switch</a> &#8216;in kullanımı oldukca basittir. Bu örnekte $Adiniz isimli bir değişken tanımladık ve değişkene Hüseyin değerini verdik. Sonrasında <a title="Switch" href="http://www.flashcentury.net/index.php/tag/switch">Switch</a> &#8216;ten $Adiniz isimli değiskeni kontrol etmisini istedik. Bu kodu çalıştırdığınızda ile <a title="Case" href="http://www.flashcentury.net/index.php/tag/case">Case</a> &#8216;nin koşulu olan &#8220;Hüseyin&#8221; doğru olduğu için ekranda &#8220;Merhaba Hüseyin&#8221; yazacaktir.</p>
<p>ilk <a title="Case" href="http://www.flashcentury.net/index.php/tag/case">Case</a> denememiz de koşul yerine geldi ve <a title="Break" href="http://www.flashcentury.net/index.php/tag/break">break </a>komutunu kullandığımız için, <a title="Swıtch" href="http://www.flashcentury.net/index.php/tag/switch">Switch</a> içerisinde yeralan diğer şartlar kontrol edilmeden <a title="Swıtch" href="http://www.flashcentury.net/index.php/tag/switch">switch</a> islemi bitecektir, bu kullanım şekli kodunuzun daha sağlıklı ve hızlı çalışması için size tavsiyemdir fakat break parametresini kullanmasaydık birinci koşuldaki $Adiniz isimli değiskenin değeri &#8220;Hüseyin&#8221; olsa dahi diğer şartlarıda kontrol edecekti.</p>
<p>Şimdi biraz daha ise yarar bir örnek yapalim;</p>
<pre class="brush: php;">
$Ay = 5;

switch ($Ay)
{
case 1:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Ocak&quot; ;
break

case 2:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Şubat&quot; ;
break

case 3:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Mart&quot; ;
break

case 4:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Nisan&quot; ;
break

case 5:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Mayıs&quot; ;
break

case 6:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Haziran&quot; ;
break

case 7:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Temmuz&quot; ;
break

case 8:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Ağustos&quot; ;
break

case 9:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Eylül&quot; ;
break

case 10:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Ekim&quot; ;
break

case 11:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Kasim&quot; ;
break

case 12:
&lt;a href=&quot;http://www.php.net/echo&quot;&gt;echo&lt;/a&gt; &quot;Aralık&quot; ;
break

default
echo &quot;Girdiğiniz ay doğru değil, Lütfen kontrol ediniz&quot;;
}
</pre>
<p>Yukarıdaki kodu çalıştırdığımızda $ay değişkenının değeri 5 olduğu için ekranda Mayıs yazacaktır.</p>
<p>Aynı işlemi <a title="else" href="http://www.flashcentury.net/index.php/tag/else">if else</a> ile de yapabiliz fakat yukarıdaki gibi çok seçenekli bir mantıksal sorgulama da daha iyi bir performans için <a title="Switch" href="http://www.flashcentury.net/index.php/tag/Switch">Switch</a> metodunu kullanmanızı tavsiye ederim.</p>
<p><span style="color: #ff0000;"><span style="color: #000000;"><br />
</span></span></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;t=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29" rel="nofollow" class="external" title="Bunu paylaş:Facebook">Bunu paylaş:Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29+-+http://b2l.me/v724k&amp;source=shareaholic" rel="nofollow" class="external" title="Bunu Tweet'le!">Bunu Tweet'le!</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29&amp;link=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html" rel="nofollow" class="external" title="Bunu paylaş:FriendFeed">Bunu paylaş:FriendFeed</a>
		</li>
		<li class="shr-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;t=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29" rel="nofollow" class="external" title="Bunu postala:MySpace">Bunu postala:MySpace</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;title=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29" rel="nofollow" class="external" title="Bunu Digg'le!">Bunu Digg'le!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;title=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29" rel="nofollow" class="external" title="Bunu paylaş:del.icio.us">Bunu paylaş:del.icio.us</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29&amp;body=Link: http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html (shareaholic aracılığıyla)%0D%0A%0D%0A----%0D%0A Bir%20%C3%B6nceki%20Php%20dersimizde%20if%20ve%20else%20ile%20mant%C4%B1ksal%20ifadeleri%20kullanmay%C4%B1%20anlatm%C4%B1%C5%9Ft%C4%B1m%2C%20%C5%9Fimdi%20ise%20Php%20%27de%20matiksal%20ifadelerin%20di%C4%9Fer%20bir%20alternatifi%20olan%20switch%20deyimini%20anlataca%C4%9F%C4%B1m.%0D%0A%0D%0ASwitch%20%27in%20kullan%C4%B1m%20mant%C4%B1%C4%9F%C4%B1%20oldukca%20basittir.%0D%0Aswitch%20%28%20de%C4%9Fi%C5%9Fken%20%29%20%0D%0A%7B%0D%0Acase%20Ko%C5%9Ful%3B%0D%0A%20Ko%C5%9Ful%20do%C4%9Fru%20i" rel="nofollow" class="external" title="Bunu e-postala:Yahoo! Mail">Bunu e-postala:Yahoo! Mail</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;title=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29" rel="nofollow" class="external" title="İyi bir şeye mi denk geldin? StumbleUpon üzerinde paylaş">İyi bir şeye mi denk geldin? StumbleUpon üzerinde paylaş</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;title=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29" rel="nofollow" class="external" title="Bunu paylaş:Reddit">Bunu paylaş:Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;title=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29&amp;summary=Bir%20%C3%B6nceki%20Php%20dersimizde%20if%20ve%20else%20ile%20mant%C4%B1ksal%20ifadeleri%20kullanmay%C4%B1%20anlatm%C4%B1%C5%9Ft%C4%B1m%2C%20%C5%9Fimdi%20ise%20Php%20%27de%20matiksal%20ifadelerin%20di%C4%9Fer%20bir%20alternatifi%20olan%20switch%20deyimini%20anlataca%C4%9F%C4%B1m.%0D%0A%0D%0ASwitch%20%27in%20kullan%C4%B1m%20mant%C4%B1%C4%9F%C4%B1%20oldukca%20basittir.%0D%0Aswitch%20%28%20de%C4%9Fi%C5%9Fken%20%29%20%0D%0A%7B%0D%0Acase%20Ko%C5%9Ful%3B%0D%0A%20Ko%C5%9Ful%20do%C4%9Fru%20i&amp;source=Flashcentury" rel="nofollow" class="external" title="Bunu paylaş:LinkedIn">Bunu paylaş:LinkedIn</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html&amp;title=Php+%E2%80%98de+Mant%C4%B1ksal+%C4%B0fadeler+%28Switch%29" rel="nofollow" class="external" title="Bunu ekle:Google Bookmarks">Bunu ekle:Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.flashcentury.net/php-de-mantiksal-ifadeler-switch.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
