<?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>NewSourceMedia Blog &#187; phone number</title>
	<atom:link href="http://newsourcemedia.com/blog/tag/phone-number/feed/" rel="self" type="application/rss+xml" />
	<link>http://newsourcemedia.com/blog</link>
	<description>Focused on Interactive Design, Development and Marketing</description>
	<lastBuildDate>Mon, 07 May 2012 01:26:28 +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 Validation Numbers Only From</title>
		<link>http://newsourcemedia.com/blog/php-validation-numbers-only-from/</link>
		<comments>http://newsourcemedia.com/blog/php-validation-numbers-only-from/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Forms]]></category>
		<category><![CDATA[Math and Numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[credit card]]></category>
		<category><![CDATA[digit]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[phone number]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[validate]]></category>
		<category><![CDATA[zip code]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-validation-numbers-only-from/</guid>
		<description><![CDATA[How to check for number values only and block or convert letter strings to integers. Question: How to validate number values to and block all letters and symbol in a form. Answer: You can check the value or convert the &#8230; <a href="http://newsourcemedia.com/blog/php-validation-numbers-only-from/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to check for number values only and block or convert letter strings to integers.
<span id="more-170"></span>

<strong>Question:</strong> How to validate number values to and block all letters and symbol in a form.

<strong>Answer:</strong> You can check the value or convert the value to an integer (number).

1) Check a value using is_int() to finds whether the given variable is an integer

<code>&lt;?
if(is_int($variable))
echo "Pass test";
else
echo "Please use only numbers";
?&gt; </code>

2) Note: To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().

<code>&lt;?
if(is_numeric($variable))
echo "Pass test";
else
echo "Please use only numbers";
?&gt; </code>

3) Convert the value to an integer (number) using settype.

<code>&lt;?php
$foo = "5bar"; // string
$bar = true; // boolean</code>

settype($foo, "integer"); // $foo is now 5 (integer)
settype($bar, "string"); // $bar is now "1" (string)
?&gt;

or you can use int to do the trick.

<code>
&lt;?
$int=593; // $int is a integer
$int.=""; // $int is now a string
?&gt;
</code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-validation-numbers-only-from/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
