<?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>Web Development London UK &#187; php</title>
	<atom:link href="http://hsmoore.com/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://hsmoore.com</link>
	<description>Web Development London UK</description>
	<lastBuildDate>Wed, 01 Feb 2012 12:10:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Remove all linebreaks in PHP</title>
		<link>http://hsmoore.com/blog/remove-all-linebreaks-in-php/</link>
		<comments>http://hsmoore.com/blog/remove-all-linebreaks-in-php/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 09:22:57 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://hsmoore.com/?p=1408</guid>
		<description><![CDATA[If you are having problems with a string that keeps adding a line break when output from PHP to HTML then the following code will work wonders for you! $string_with_line_break = &#34;blabla\nbla\r&#34;; $string_without_line_break = trim&#40;preg_replace&#40; &#34;/\s+/&#34;,&#34;&#34;,$string_with_line_break&#41;&#41;;]]></description>
			<content:encoded><![CDATA[<p>If you are having problems with a string that keeps adding a line break when output from PHP to HTML then the following code will work wonders for you!</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$string_with_line_break</span> <span class="sy0">=</span> <span class="st0">&quot;blabla<span class="es1">\n</span>bla<span class="es1">\r</span>&quot;</span><span class="sy0">;</span><br />
<span class="re0">$string_without_line_break</span> <span class="sy0">=</span> <a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><a href="http://www.php.net/preg_replace"><span class="kw3">preg_replace</span></a><span class="br0">&#40;</span> <span class="st0">&quot;/\s+/&quot;</span><span class="sy0">,</span><span class="st0">&quot;&quot;</span><span class="sy0">,</span><span class="re0">$string_with_line_break</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/remove-all-linebreaks-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace all spaces in HTML with &#160; except in HTML tags using PHP</title>
		<link>http://hsmoore.com/blog/replace-all-spaces-in-html-with-except-in-html-tags-using-php/</link>
		<comments>http://hsmoore.com/blog/replace-all-spaces-in-html-with-except-in-html-tags-using-php/#comments</comments>
		<pubDate>Sun, 29 May 2011 16:56:13 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[nbsp]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1251</guid>
		<description><![CDATA[If you would like to replace all the spaces in an HTML string with &#38;nbsp; so that you can render it out to the browser but you also want to retain current spaces in HTML tags you can use the below method: $inputString = &#8216;&#60;span class=&#34;color:red&#34;&#62;1&#60;/span&#62; 2 &#160; &#160; &#160; &#160;3&#8242;; $outputString = preg_replace_callback&#40;&#34;#&#38;gt;[^&#38;lt;]+&#38;lt;#&#34;,&#34;relSpaces&#34;,$inputString&#41;; function...]]></description>
			<content:encoded><![CDATA[<p>If you would like to replace all the spaces in an HTML string with &amp;nbsp; so that you can render it out to the browser but you also want to retain current spaces in HTML tags you can use the below method:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$inputString</span> <span class="sy0">=</span> <span class="st_h">&#8216;&lt;span class=&quot;color:red&quot;&gt;1&lt;/span&gt; 2 &nbsp; &nbsp; &nbsp; &nbsp;3&#8242;</span><span class="sy0">;</span><br />
<span class="re0">$outputString</span> <span class="sy0">=</span> <a href="http://www.php.net/preg_replace_callback"><span class="kw3">preg_replace_callback</span></a><span class="br0">&#40;</span><span class="st0">&quot;#&amp;gt;[^&amp;lt;]+&amp;lt;#&quot;</span><span class="sy0">,</span><span class="st0">&quot;relSpaces&quot;</span><span class="sy0">,</span><span class="re0">$inputString</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="kw2">function</span> relSpaces<span class="br0">&#40;</span><span class="re0">$match</span><span class="br0">&#41;</span><span class="br0">&#123;</span><span class="kw1">return</span> <a href="http://www.php.net/str_replace"><span class="kw3">str_replace</span></a><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span><span class="sy0">,</span><span class="st0">&quot; &quot;</span><span class="sy0">,</span><span class="re0">$match</span><span class="br0">&#91;</span>0<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><span class="br0">&#125;</span></div>
</div>
<p><span style="text-decoration: underline;">This will replace:</span><br />
&#8220;&lt;span&gt;1&lt;/span&gt; 2        3&#8243;</p>
<p><span style="text-decoration: underline;">..to look like this:</span><br />
&#8220;&lt;span&gt;1&lt;/span&gt;&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&#8243;</p>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/replace-all-spaces-in-html-with-except-in-html-tags-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP to validate an IP address</title>
		<link>http://hsmoore.com/blog/using-php-to-validate-an-ip-address/</link>
		<comments>http://hsmoore.com/blog/using-php-to-validate-an-ip-address/#comments</comments>
		<pubDate>Wed, 18 May 2011 08:47:13 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[filter_var]]></category>
		<category><![CDATA[ip address]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1247</guid>
		<description><![CDATA[You can use the PHP code below to check if an IP address is valid or not. $ip = &#34;&#34;; //enter a valid or invalid ip address here if&#40;filter_var&#40;$ip, FILTER_VALIDATE_IP&#41;&#41; &#123; // The IP Address is valid &#125; else &#123; // The IP Address is not valid &#125; Wasn&#8217;t that easy!?!]]></description>
			<content:encoded><![CDATA[<p>You can use the PHP code below to check if an IP address is valid or not.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$ip</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span> <span class="co1">//enter a valid or invalid ip address here</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/filter_var"><span class="kw3">filter_var</span></a><span class="br0">&#40;</span><span class="re0">$ip</span><span class="sy0">,</span> FILTER_VALIDATE_IP<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co1">// The IP Address is valid</span><br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
<span class="co1">// The IP Address is not valid</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Wasn&#8217;t that easy!?!</p>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/using-php-to-validate-an-ip-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide all error messages PHP</title>
		<link>http://hsmoore.com/blog/hide-all-error-messages-php/</link>
		<comments>http://hsmoore.com/blog/hide-all-error-messages-php/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 09:03:20 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1223</guid>
		<description><![CDATA[PHP Error messages showing up in your web applications are a dangerous thing. Not only does it look unprofessional, but it is also a serious security concern! Once you have completed debugging your website or web application you can place the following one liner at the beginning of your code, this will turn off error...]]></description>
			<content:encoded><![CDATA[<p>PHP Error messages showing up in your web applications are a dangerous thing. Not only does it look unprofessional, but it is also a serious security concern!</p>
<p>Once you have completed debugging your website or web application you can place the following one liner at the beginning of your code, this will turn off error reporting and therefore make sure that no application details are spilled to your users.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><a href="http://www.php.net/error_reporting"><span class="kw3">error_reporting</span></a><span class="br0">&#40;</span>0<span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>If a single line of code is causing the problems it is safer to use the at symbol (@) to suppress any errors it may cause.<br />
You can also use &#8220;or die()&#8221; to stop the execution of your code after the suppressed error incase the remainder of your code relies on that function to return a value.<br />
In the example below we will use the &#8220;@&#8221; and &#8220;or die&#8221; to handle everything:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="sy0">@</span><a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&quot;SELECT * FROM `anInvalidTableName`&quot;</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;There was an error! &quot;</span><span class="sy0">.</span><a href="http://www.php.net/mysql_error"><span class="kw3">mysql_error</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>It is also good practise to make sure that all variables are set and are not empty before trying to access them.</p>
<p>For example:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$myVar</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$myVar</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co1">// $myVar is now safe to use!</span><br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/hide-all-error-messages-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What is xmlrpc.php?</title>
		<link>http://hsmoore.com/blog/what-is-xmlrpc-php/</link>
		<comments>http://hsmoore.com/blog/what-is-xmlrpc-php/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 11:02:59 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1197</guid>
		<description><![CDATA[It is a script which allows clients to make procedural calls over the net. As it says in the name, the encoding is XML and because it is used on websites we can make the fair assessment that it uses the HTTP protocol. If we break the name down we get: XML transmition via Remote...]]></description>
			<content:encoded><![CDATA[<p>It is a script which allows clients to make procedural calls over the net.<br />
As it says in the name, the encoding is XML and because it is used on websites we can make the fair assessment that it uses the HTTP protocol.</p>
<p>If we break the name down we get: XML transmition via Remote Procedure Calls.</p>
<p>So you are still not sure what this is all about? Read on..</p>
<p>xmlrpc.com has a very simple yet rather effective diagram which illustrates what&#8217;s going on with it all:</p>
<p><img class="size-full wp-image-1198 alignnone" title=" " src="http://andrewodendaal.com/wp-content/uploads/2011/02/xmlrpc1.jpg" alt="" width="527" height="270" /></p>
<p>As we can see above, xmlrpc is basically a simple way of transporting data using a common protocol used on the web.</p>
<p>This file is usually added to the root of a domain when using packages such as WordPress, Drupal or similar.</p>
<p>XMLRPC.php only accepts POST requests so using the CURL library or similar would be the best option when interacting with it. The PHP source file is quite long so I will not include it here, as it is 3375lines long. But you can easily find it online using your favorite search engine!</p>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/what-is-xmlrpc-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop That Referrer in PHP!</title>
		<link>http://hsmoore.com/blog/stop-that-referrer-in-php/</link>
		<comments>http://hsmoore.com/blog/stop-that-referrer-in-php/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 12:34:50 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[referrer]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1161</guid>
		<description><![CDATA[Today I will show you a method to stop the traffic that a referrer site is sending your way, you may wonder why you would want to ignore traffic, after all, isn&#8217;t inbound traffic to your site fantastic no matter what? The simple answer is &#8220;NO!&#8221; Let me explain it in a real life situation...]]></description>
			<content:encoded><![CDATA[<p>Today I will show you a method to stop the traffic that a referrer site is sending your way, you may wonder why you would want to ignore traffic, after all, isn&#8217;t inbound traffic to your site fantastic no matter what?</p>
<p>The simple answer is &#8220;NO!&#8221;</p>
<p>Let me explain it in a real life situation so that you can better understand where to use this.</p>
<p><strong>Understanding where to use it</strong></p>
<p>You have a site that is using a web service or API of yours and it is sending loads of unwanted traffic your way, you actually want the service to be equally distributed but this one particular site is just overdoing it. So you want to stop all their traffic to you and only allow proper direct API requests or whatever the case.</p>
<p><strong>Now for some code</strong></p>
<p>At the very top of the php page that is being called &#8211; in our example we will call it &#8220;http://andrewodendaal.com/api/&#8221; &#8211; you will add in the following PHP code:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/strstr"><span class="kw3">strstr</span></a><span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st_h">&#8216;HTTP_REFERER&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span><span class="st0">&quot;theotherdomain.com&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&quot;Location: http://theotherdomain.com&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Make sure to add this code before any other code or rendering objects, otherwise you will receive a PHP error!</p>
<p><strong>Explaining the code</strong></p>
<p>What this code will do: it will check to see if the visitor came from that site or was somehow referred from it and it will just send them back to that site&#8217;s homepage.</p>
<p><strong>And bandwidth?</strong></p>
<p>This technique does not get rid of the bandwidth used up entirely as the visitor still connects to your site, but it does not show the user anything as the php redirection header kicks in prior to any browser rendering. So as they click on the link at the original site, it immediately takes them to that site&#8217;s homepage. Very minimal bandwidth usage occurs during this period.</p>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/stop-that-referrer-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error 500 php_value .htaccess</title>
		<link>http://hsmoore.com/blog/error-500-php_value-htaccess/</link>
		<comments>http://hsmoore.com/blog/error-500-php_value-htaccess/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 12:00:23 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[php_value]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1090</guid>
		<description><![CDATA[I noticed on some server setups I could not do the following inside a .htacess file: php_value upload_max_filesize 250M php_value post_max_size 250M I was getting an error 500 Internal Server Error with the above code in the .htaccess file. What to do to correct this is create a file called php.ini and save it in...]]></description>
			<content:encoded><![CDATA[<p>I noticed on some server setups I could not do the following inside a .htacess file:</p>
<div class="codesnip-container" >php_value upload_max_filesize 250M<br />
php_value post_max_size 250M</div>
<p>I was getting an error 500 Internal Server Error with the above code in the .htaccess file.</p>
<p>What to do to correct this is create a file called php.ini and save it in the same location as your .htaccess file and enter the following code instead:</p>
<div class="codesnip-container" >upload_max_filesize = &#8220;250M&#8221;<br />
post_max_size = &#8220;250M&#8221;</div>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/error-500-php_value-htaccess/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS background image data: base64?</title>
		<link>http://hsmoore.com/blog/css-background-image-data-base64/</link>
		<comments>http://hsmoore.com/blog/css-background-image-data-base64/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 15:22:53 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[Data URL]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1067</guid>
		<description><![CDATA[What the heck is all that Gobbledygook in the CSS? So you have noticed that bit of css that says something like this in the CSS source-code and you have no idea what it could be? url(&#8220;data:image/gif;base64,R0lGODlfMAMEAIABAKysrObm5iH5BAEAAAEALAAAAAAwAwQAAAJOhI+py30Bo5y02ouz3rz7D4biSJbmiabqyrbuC8fyTKPOjedHzff+DwwKh8Si8YhMKku6pvOxjEqn1Kr1is1qt7ynV8cNi8fksvmMTiMLAD4=&#8221;) no-repeat scroll 50% 0 transparent It is a technique called Data URLs and using PHP &#8211; or your...]]></description>
			<content:encoded><![CDATA[<p>What the heck is all that <a title="Opens in a new tab/window" href="http://en.wikipedia.org/wiki/Gobbledygook" target="_blank">Gobbledygook</a> in the CSS?</p>
<p>So you have noticed that bit of css that says something like this in the CSS source-code and you have no idea what it could be?<br />
<em><span style="color: #ff0000; font-size: 7px;">url(&#8220;data:image/gif;base64,R0lGODlfMAMEAIABAKysrObm5iH5BAEAAAEALAAAAAAwAwQAAAJOhI+py30Bo5y02ouz3rz7D4biSJbmiabqyrbuC8fyTKPOjedHzff+DwwKh8Si8YhMKku6pvOxjEqn1Kr1is1qt7ynV8cNi8fksvmMTiMLAD4=&#8221;) no-repeat scroll 50% 0 transparent</span></em></p>
<p>It is a technique called Data URLs and using PHP &#8211; or your favourite server-side script &#8211; you can generate these nifty little things.</p>
<p><strong>An example of how to generate it in PHP:</strong></p>
<div class="codesnip-container" >.myClassName {<br />
   background: url(data:image/gif;base64,&lt;?php echo base64_encode(file_get_contents(&#8220;../images/folder16.gif&#8221;)) ?&gt;) top left no-repeat;<br />
}</div>
<p><strong>What you need to know over and above:</strong><br />
You will need to have your CSS file(s) saved as in the PHP extension ( e.g. myCSSFile.php ).<br />
This allows the server to process the PHP code contained in the CSS, so in a way you have a dynamic CSS file creator.</p>
<p><strong>What&#8217;s so good about Data URLs?</strong><br />
They aren&#8217;t all that weird after all, they actually help conserve bandwidth due to less HTTP requests. This brings us to the next step you need to know!</p>
<p><strong>Caching problems!</strong><br />
The problem with this approach is that you will need to recalculate the string everytime you change the image, otherwise browsers tend to cache what they remember seeing and use that instead!</p>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/css-background-image-data-base64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP&#039;s typeof &#8211; gettype()</title>
		<link>http://hsmoore.com/blog/phps-typeof-gettype/</link>
		<comments>http://hsmoore.com/blog/phps-typeof-gettype/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 07:47:30 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[gettype]]></category>
		<category><![CDATA[typeof]]></category>

		<guid isPermaLink="false">http://andrewodendaal.com/?p=1027</guid>
		<description><![CDATA[Quite often you may need the ability to check what type of data type a variable is. In most programming languages this is possible to do and is usually called typeof(). PHP too has a way to check this, it is called gettype() and it&#8217;s so simple to use. All you have to do is...]]></description>
			<content:encoded><![CDATA[<p>Quite often you may need the ability to check what type of data type a variable is.</p>
<p>In most programming languages this is possible to do and is usually called <strong>typeof()</strong>.<br />
PHP too has a way to check this, it is called <strong>gettype()</strong> and it&#8217;s so simple to use.</p>
<p>All you have to do is echo out a call to <strong>gettype()</strong> with your variable as the first argument.</p>
<p>Like so:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">function</span> foo<span class="br0">&#40;</span><span class="re0">$bar</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw1">echo</span> <a href="http://www.php.net/gettype"><span class="kw3">gettype</span></a><span class="br0">&#40;</span><span class="re0">$bar</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
foo<span class="br0">&#40;</span><span class="st0">&quot;stringVar);<br />
//echo&#8217;s &quot;</span>stringVar<span class="st0">&quot;;<br />
foo(<span class="es4">$arrayVar</span>);<br />
//echo&#8217;s &quot;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="st0">&quot;;</span></div>
</div>
<p>In the above script we create a function called foo which has 1 argument, it can take any data type so we call it twice, one with a string argument and secondly with an array argument.</p>
<p>Read the official documentation on <a title="Opens in new tab/window" href="http://php.net/manual/en/function.gettype.php" target="_blank">gettype here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/phps-typeof-gettype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript 2 &amp; PHP Data Transfer</title>
		<link>http://hsmoore.com/blog/actionscript-2-php-data-transfer/</link>
		<comments>http://hsmoore.com/blog/actionscript-2-php-data-transfer/#comments</comments>
		<pubDate>Mon, 17 May 2010 11:09:32 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Article]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.andrewodendaal.com/?p=824</guid>
		<description><![CDATA[In the below example we will use Actionscript 2 to call a remote PHP file that will return data to it. It is a simple way of transferring data between the server and client. Actionscript 2 Code: callRemoteFile = function&#40;ourVariable:String&#41; &#123; &#160; &#160; &#160; &#160; var result_lv:LoadVars = new LoadVars&#40;&#41;; &#160; &#160; result_lv.onLoad = function&#40;success:Boolean&#41;...]]></description>
			<content:encoded><![CDATA[<p>In the below example we will use Actionscript 2 to call a remote PHP file that will return data to it.<br />
It is a simple way of transferring data between the server and client.</p>
<h3>Actionscript 2 Code:</h3>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">callRemoteFile = <span class="kw2">function</span><span class="br0">&#40;</span>ourVariable:<span class="kw3">String</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> result_lv:<span class="kw3">LoadVars</span> = <span class="kw2">new</span> <span class="kw3">LoadVars</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; result_lv.<span class="kw3">onLoad</span> = <span class="kw2">function</span><span class="br0">&#40;</span>success:<span class="kw3">Boolean</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>success<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>result_lv.<span class="kw3">message</span>==<span class="st0">&quot;success&quot;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span><span class="st0">&quot;done! &quot;</span>+result_lv.<span class="me1">returnValue</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span>result_lv.<span class="kw3">message</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span><span class="st0">&quot;Error connecting to server&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span>;<br />
&nbsp; &nbsp; <span class="kw2">var</span> send_lv:<span class="kw3">LoadVars</span> = <span class="kw2">new</span> <span class="kw3">LoadVars</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; send_lv.<span class="me1">ourVariable</span> = ourVariable;<br />
&nbsp; &nbsp; send_lv.<span class="kw3">sendAndLoad</span><span class="br0">&#40;</span><span class="st0">&quot;http://www.andrewodendaal.com/example/file.php&quot;</span>, result_lv, <span class="st0">&quot;POST&quot;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
callRemoteFile<span class="br0">&#40;</span><span class="st0">&quot;some text here&quot;</span><span class="br0">&#41;</span>;</div>
</div>
<h3>PHP Code:</h3>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">echo</span> <span class="st0">&quot;a=1&amp;message=success&amp;returnValue=&quot;</span><span class="sy0">.</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&quot;ourVariable&quot;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st0">&quot;&amp;b=2&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="kw1">echo</span> <span class="st0">&quot;a=0&amp;message=failed&amp;returnValue=nothing&amp;b=1&quot;</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hsmoore.com/blog/actionscript-2-php-data-transfer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

