Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: bug in is_numeric Date: Mon, 13 May 2013 19:55:01 +0200 Lines: 55 Message-ID: References: <5190d3a0$0$15991$e4fe514c@news2.news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net q4LGJSQNaDe76KAycmmlWwO6otOmnV8fZMbBHwxy00U3WsQ6eq Cancel-Lock: sha1:0neypB/PeLUWC1OuVz0Fp0N0KLY= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130408 Thunderbird/17.0.5 In-Reply-To: Xref: csiph.com comp.lang.php:9305 On 13/05/13 16:15, fred wrote: > Otherwise I'm done repeating myself. > > > if(is_numeric('x11.11c') returns TRUE > > > and variations eg: z1111x is also true > > > > Could you try the following code and let me know what comes out? > > > > OK I get false when I do that. > "bool(false)" to be more precise. > var_export($a)also reports false if thats any help. > > I have just typed in an exact copy of the test in my message of 02:58pm > When you have run that on an apache PHP installation of the same version > PHP as I listed (5.3.6) under windows7-64 bit - get back to me. Apparently there is nothing wrong with your is_numeric() as you state var_export did return "bool(false)" which is the expected result. you fail to show the code you actually used (the example you gave don't have correct syntax, so I doubt it's from your actual code, just something you wrote). As other already pointed out, you are most likely expecting a specific value to been set, but most likely it's another value (bad coding which uses "global" values which are used in many functions will in most cases have a more random nature of what value it will have) or that your if-statement includes a negation for example: if(!is_numeric("abcdef")) { echo "my code is buggy, not is_numeric()\n"; } By the way, var_export() don't return false, it will return null by default or a string (if you set the return argument to true). If you made a check on what var_export() returned and you got it to be equal to false, then your method of checking the return value is utterly flawed. The release of PHP 5.3.6 is over two years ago, and if there had been a bug, then it had been discovered a lot earlier than now on a function which is heavily used in a lot of PHP code and the code base isn't platform dependent. My recommendation would be to upgrade to 5.4.14, if you can't find it for your OS, then upgrade to one which provides it. -- //Aho