<?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>ikapeng.com &#187; Php</title>
	<atom:link href="http://www.ikapeng.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ikapeng.com</link>
	<description>แลกเปลี่ยนความรู้,แชร์ความรู้,สังคมแลกเปลี่ยนเรียนรู้</description>
	<lastBuildDate>Wed, 11 Jan 2012 15:07:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>แก้ปัญหาตัวแปร register_globals เป็น off [$_POST] [$_GET]</title>
		<link>http://www.ikapeng.com/%e0%b9%81%e0%b8%81%e0%b9%89%e0%b8%9b%e0%b8%b1%e0%b8%8d%e0%b8%ab%e0%b8%b2%e0%b8%95%e0%b8%b1%e0%b8%a7%e0%b9%81%e0%b8%9b%e0%b8%a3-register_globals-%e0%b9%80%e0%b8%9b%e0%b9%87%e0%b8%99-off-_post-_get/</link>
		<comments>http://www.ikapeng.com/%e0%b9%81%e0%b8%81%e0%b9%89%e0%b8%9b%e0%b8%b1%e0%b8%8d%e0%b8%ab%e0%b8%b2%e0%b8%95%e0%b8%b1%e0%b8%a7%e0%b9%81%e0%b8%9b%e0%b8%a3-register_globals-%e0%b9%80%e0%b8%9b%e0%b9%87%e0%b8%99-off-_post-_get/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 04:12:14 +0000</pubDate>
		<dc:creator>ikapeng</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[ทิป-เทคนิคคอมพิวเตอร์]]></category>
		<category><![CDATA[register_globals]]></category>
		<category><![CDATA[ตัวแปร register_globals]]></category>

		<guid isPermaLink="false">http://www.ikapeng.com/?p=296</guid>
		<description><![CDATA[บางครั้ง server จะมีการปิดตัวแปร register_globals ทำให้เมื่อมีการเรียกใช้ตัวแปรเกิดปํญหา ตัวอย่างเช่น เราส่งตัวแปร $_GET['var'] แต่ตอนเรียกใช้ เราเรียกใช้เป็น $var หรือกรณีที่ เราส่งตัวแปร $_POST['name'] แต่ตอนเรียกใช้ เราเรียกใช้เป็น $name หากตัวแปร register_globals เปิด ปัญหาก็จะไม่เกิดขั้น แต่กรณีตัวแปร register_globals ปิด ปัญหาก็จะเกิดคือ ตัวแปรที่เราเรียกใช้จะไม่มีค่าใดส่งเข้ามาเลย วิธีการแก้ปัญหาวิธีหนึ่งคือ การใช้ ค่ำสั่ง foreach ดังนี้ &#60;?php foreach($_POST as $key=&#62;$value) { $$key=$value; } foreach($_GET as $key=&#62;$value) { $$key=$value; } ?&#62; &#160; แล้วเราก็ใช้ตัวแปรได้ตามปกติครับ http://moshikub.com/วิธีแก้ปัญหาตัวแปร-global-off/]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ikapeng.com/wp-content/uploads/2011/12/php.jpg" rel="lightbox[296]"><img class="aligncenter size-full wp-image-297" title="php" src="http://www.ikapeng.com/wp-content/uploads/2011/12/php.jpg" alt="" width="578" height="406" /></a>บางครั้ง server จะมีการปิด<a href="http://www.ikapeng.com/แก้ปัญหาตัวแปร-register_globals-เป็น-off-_post-_get/">ตัวแปร register_globals</a> ทำให้เมื่อมีการเรียกใช้ตัวแปรเกิดปํญหา  ตัวอย่างเช่น เราส่งตัวแปร $_GET['var'] แต่ตอนเรียกใช้ เราเรียกใช้เป็น $var</p>
<p>หรือกรณีที่ เราส่งตัวแปร $_POST['name']  แต่ตอนเรียกใช้ เราเรียกใช้เป็น $name หาก<a href="http://www.ikapeng.com/%E0%B9%81%E0%B8%81%E0%B9%89%E0%B8%9B%E0%B8%B1%E0%B8%8D%E0%B8%AB%E0%B8%B2%E0%B8%95%E0%B8%B1%E0%B8%A7%E0%B9%81%E0%B8%9B%E0%B8%A3-register_globals-%E0%B9%80%E0%B8%9B%E0%B9%87%E0%B8%99-off-_post-_get/">ตัวแปร register_globals</a> เปิด  ปัญหาก็จะไม่เกิดขั้น แต่กรณีตัวแปร register_globals ปิด ปัญหาก็จะเกิดคือ ตัวแปรที่เราเรียกใช้จะไม่มีค่าใดส่งเข้ามาเลย  วิธีการแก้ปัญหาวิธีหนึ่งคือ  การใช้ ค่ำสั่ง foreach ดังนี้</p>
<pre class="brush: php; ">

&lt;?php
foreach($_POST as $key=&gt;$value)
{
$$key=$value;
}
foreach($_GET as $key=&gt;$value)
{
$$key=$value;
}
?&gt;
</pre>
<p>&nbsp;</p>
<p>แล้วเราก็ใช้ตัวแปรได้ตามปกติครับ</p>
<p>http://moshikub.com/วิธีแก้ปัญหาตัวแปร-global-off/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ikapeng.com/%e0%b9%81%e0%b8%81%e0%b9%89%e0%b8%9b%e0%b8%b1%e0%b8%8d%e0%b8%ab%e0%b8%b2%e0%b8%95%e0%b8%b1%e0%b8%a7%e0%b9%81%e0%b8%9b%e0%b8%a3-register_globals-%e0%b9%80%e0%b8%9b%e0%b9%87%e0%b8%99-off-_post-_get/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

