<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: PHP:  Validating Numeric Values and&#160;Digits</title> <atom:link href="http://davidwalsh.name/php-validatie-numeric-digits/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/php-validatie-numeric-digits</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 19:56:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Allain Lalonde</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-28986</link> <dc:creator>Allain Lalonde</dc:creator> <pubDate>Fri, 03 Feb 2012 15:33:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-28986</guid> <description>Doesn&#039;t &#039;/[0-9]+/&#039; equate to contains or or more consecutive digits. For all, I think you probably need &#039;/^[0-9]+$/&#039; or more succinctly &#039;/^\d+$/&#039;.Kudos to Elkalidi Abdelkader for using them but it doesn&#039;t hurt to be explicit.</description> <content:encoded><![CDATA[<p>Doesn&#8217;t &#8216;/[0-9]+/&#8217; equate to contains or or more consecutive digits. For all, I think you probably need &#8216;/^[0-9]+$/&#8217; or more succinctly &#8216;/^\d+$/&#8217;.</p><p>Kudos to Elkalidi Abdelkader for using them but it doesn&#8217;t hurt to be explicit.</p> ]]></content:encoded> </item> <item><title>By: endryou</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-4216</link> <dc:creator>endryou</dc:creator> <pubDate>Tue, 16 Dec 2008 12:45:35 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-4216</guid> <description>One important detail about ctype&#095;digit: it accepts string as parameter.
For example:
ctype&#095;digit(&#039;5&#039;) === true, but ctype&#095;digit(5) === false.
So it&#039;s safer to write ctype&#095;digit((string)$my&#095;fancy&#095;var) but again not enough for nulls,
booleans, objects or resources.</description> <content:encoded><![CDATA[<p>One important detail about ctype&#95;digit: it accepts string as parameter.<br
/> For example:<br
/> ctype&#95;digit(&#8217;5&#8242;) === true, but ctype&#95;digit(5) === false.<br
/> So it&#8217;s safer to write ctype&#95;digit((string)$my&#95;fancy&#95;var) but again not enough for nulls,<br
/> booleans, objects or resources.</p> ]]></content:encoded> </item> <item><title>By: Elkalidi Abdelkader</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3929</link> <dc:creator>Elkalidi Abdelkader</dc:creator> <pubDate>Mon, 24 Nov 2008 00:36:24 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3929</guid> <description>to check numeric variable and lenth of variable = 4 numbers:preg_match(&quot;#^[0-9]{4}$#&quot;,$variable)exemple :
$year = preg_match(&quot;#^[0-9]{4}$#&quot;,$variable) ? $variable : date(&quot;Y&quot;);You can remplace {4} by {1,4} to check if variable is between 1 and 4 numbers</description> <content:encoded><![CDATA[<p>to check numeric variable and lenth of variable = 4 numbers:</p><p>preg_match(&#8220;#^[0-9]{4}$#&#8221;,$variable)</p><p>exemple :<br
/> $year = preg_match(&#8220;#^[0-9]{4}$#&#8221;,$variable) ? $variable : date(&#8220;Y&#8221;);</p><p>You can remplace {4} by {1,4} to check if variable is between 1 and 4 numbers</p> ]]></content:encoded> </item> <item><title>By: David</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3924</link> <dc:creator>David</dc:creator> <pubDate>Sat, 22 Nov 2008 14:31:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3924</guid> <description>Actually you can use is&#095;int() if your using the is&#095;* functions.  However Alex is right and the ctype functions are better.</description> <content:encoded><![CDATA[<p>Actually you can use is&#95;int() if your using the is&#95;* functions.  However Alex is right and the ctype functions are better.</p> ]]></content:encoded> </item> <item><title>By: Alex</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3923</link> <dc:creator>Alex</dc:creator> <pubDate>Sat, 22 Nov 2008 13:32:45 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3923</guid> <description>Josh, you can use the ctype php function :)(why my older post were deleted?)</description> <content:encoded><![CDATA[<p>Josh, you can use the ctype php function :)</p><p>(why my older post were deleted?)</p> ]]></content:encoded> </item> <item><title>By: Chris</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3921</link> <dc:creator>Chris</dc:creator> <pubDate>Sat, 22 Nov 2008 01:01:48 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3921</guid> <description>You can use is&#095;int() to find out if it&#039;s an integer instead of a regexp or having to compare using intval() (as suggested above). The only catch with this is that is must fit within the integer type range so you may still need to use a regexp if it&#039;s a really long number.And I&#039;m a little confused why you&#039;d wrap is&#095;numeric() inside another function call when all the wrapper function does is return the value from is&#095;numeric()</description> <content:encoded><![CDATA[<p>You can use is&#95;int() to find out if it&#8217;s an integer instead of a regexp or having to compare using intval() (as suggested above). The only catch with this is that is must fit within the integer type range so you may still need to use a regexp if it&#8217;s a really long number.</p><p>And I&#8217;m a little confused why you&#8217;d wrap is&#95;numeric() inside another function call when all the wrapper function does is return the value from is&#95;numeric()</p> ]]></content:encoded> </item> <item><title>By: Rikki</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3918</link> <dc:creator>Rikki</dc:creator> <pubDate>Fri, 21 Nov 2008 19:16:31 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3918</guid> <description>Why would you create a new function that returns is&#095;numeric, given that your new function name is longer than typing &#039;is&#095;numeric&#039; anyway?</description> <content:encoded><![CDATA[<p>Why would you create a new function that returns is&#95;numeric, given that your new function name is longer than typing &#8216;is&#95;numeric&#8217; anyway?</p> ]]></content:encoded> </item> <item><title>By: Brenley Dueck</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3916</link> <dc:creator>Brenley Dueck</dc:creator> <pubDate>Fri, 21 Nov 2008 18:25:16 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3916</guid> <description>I have definitely have seen people misuse the is&#095;numeric function as well.@david - a regex tutorial would be great.  You can always learn something new...</description> <content:encoded><![CDATA[<p>I have definitely have seen people misuse the is&#95;numeric function as well.</p><p>@david &#8211; a regex tutorial would be great.  You can always learn something new&#8230;</p> ]]></content:encoded> </item> <item><title>By: Brian</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3915</link> <dc:creator>Brian</dc:creator> <pubDate>Fri, 21 Nov 2008 18:05:16 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3915</guid> <description>You could also use PHP&#039;s built-in function ctype&#095;digit() which will return true only if all characters in the value it is passed are numeric. i.e. 1234 would return true, 1,234 returns false, 1.234 returns false.</description> <content:encoded><![CDATA[<p>You could also use PHP&#8217;s built-in function ctype&#95;digit() which will return true only if all characters in the value it is passed are numeric. i.e. 1234 would return true, 1,234 returns false, 1.234 returns false.</p> ]]></content:encoded> </item> <item><title>By: Josh</title><link>http://davidwalsh.name/php-validatie-numeric-digits#comment-3912</link> <dc:creator>Josh</dc:creator> <pubDate>Fri, 21 Nov 2008 17:10:25 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=783#comment-3912</guid> <description>why not just check if it&#039;s an integer and if it&#039;s a string of numbers just check if intval($num) == $num ? I tend to stray away from regex if possible.</description> <content:encoded><![CDATA[<p>why not just check if it&#8217;s an integer and if it&#8217;s a string of numbers just check if intval($num) == $num ? I tend to stray away from regex if possible.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.014 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 16:53:51 -->
