<?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>Jontas &#187; typecast</title>
	<atom:link href="http://www.f15ijp.com/tag/typecast/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.f15ijp.com</link>
	<description>My digital notepad (notes etc)</description>
	<lastBuildDate>Wed, 28 Dec 2011 18:24:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP: Converting a bool value to a string value</title>
		<link>http://www.f15ijp.com/2010/07/12/php-converting-a-bool-value-to-a-string-value/</link>
		<comments>http://www.f15ijp.com/2010/07/12/php-converting-a-bool-value-to-a-string-value/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 14:30:59 +0000</pubDate>
		<dc:creator>jontas</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[bool]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[typecast]]></category>

		<guid isPermaLink="false">http://www.f15ijp.com/?p=538</guid>
		<description><![CDATA[The first idea that comes into mind for doing this is to simply make a typecast of the boolean variable to a string and use that (which works) $testVar = false; echo &#40;string&#41;$testVar; //will output a empty string (as that evaluates to false) $testVar = true; echo &#40;string&#41;$testVar; //will output 1 (as that evaluates to [...]]]></description>
			<content:encoded><![CDATA[<p>The first idea that comes into mind for doing this is to simply make a typecast of the boolean variable to a string and use that (which works)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$testVar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$testVar</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//will output a empty string (as that evaluates to false)</span>
<span style="color: #000088;">$testVar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$testVar</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//will output 1 (as that evaluates to true)</span></pre></div></div>

<p>but what if the requirement is that the string should say true or false</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$testVar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$testVar</span> ? <span style="color: #0000ff;">'true'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'false'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//will output false</span>
<span style="color: #000088;">$testVar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$testVar</span> ? <span style="color: #0000ff;">'true'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'false'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//will output true</span></pre></div></div>

<p>(While the above example might seam useless I recently had to do this for a db insert)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.f15ijp.com/2010/07/12/php-converting-a-bool-value-to-a-string-value/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

