Re: [PHP-DEV] why is '01' == '1.'?
See http://bugs.php.net/bug.php?id=23110 It's definitely a gotcha, especially if you use switch(){}, as there is no way to do strict type checking there. Regards, Stefan -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] php 5.1.1 syntax errors
Is there any reason why the php 5.1.1 command processor does not report syntax errors despite all errors being on in the .ini file? Maybe I'm doing something stupid. -- random signature -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] why is '01' == '1.'?
On 12/14/05, Greg Beaver [EMAIL PROTECTED] wrote: In this case, a string is explicitly being compared to a string, and yet both are being converted to an int prior to comparison. I can understand that implicit type conversion is needed when comparing strings to ints, but this can be dangerous. phpDocumentor, for instance uses this code: if (in_array(substr($ltrimword, 0, 2), array('1.', '0.'))) Perhaps if (preg_match('/^[10]\./',$ltrimword)) would be both more concise and express your intent better? Regards, Jason http://blog.casey-sweat.us/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] why is '01' == '1.'?
Stefan Walk wrote: See http://bugs.php.net/bug.php?id=23110 It's definitely a gotcha, especially if you use switch(){}, as there is no way to do strict type checking there. Please reconsider the decision to leave this bug open in PHP, any unexpected behavior in an operator as fundamental as == is VERY dangerous, and if used improperly could lead to security holes (i.e. unexpectedly, input that does not match could match a strict filter based on ==) I understand the rationale behind loosely typed comparison, and use it myself, but this is beyond loosely typed, it is explicitly changing type in an irrational way, as it only applies in certain cases. Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] php 5.1.1 syntax errors
internals, it may be a badly worded (and inappropriately directed) post BUT I can categorically say that php5+ does have problems with displaying errors under certain circumstances - you see nothing anywhere regardless of ini/log/display settings. I have had such issues since php.5.0.3beta, I have never been able to reproduce the issue in a simple script (certain degree of code complexity is required - in practice that means running a 'production' framework of some sort). examples of the sort of problems that cause NOTHING to be reported, NOTHING to be logged and NOTHING to be displayed: 1. failed require/require_once statements. 2. non-abstract class with abstract methods (as declared in a base class). 3. method signature incompatibilities. when faced with such an error (like I just spent another 2 hours figuring out a newly developed class was missing a method [no. 2] - not the first time!) the only recourse I have it to start at the first line of php that is run and write something like: die(WTF IS GOING ON!?!?! :-(); and then keep moving it a line or 2 down at a time (stepping into all/any include files, of which there are normally about 25-50) until I find the offending line/file (at which point I can try to figure out what is actually wrong). Daine Mamacos wrote: Is there any reason why the php 5.1.1 command processor does not report syntax errors despite all errors being on in the .ini file? Maybe I'm doing something stupid. mee too - wish I knew what it was. -- random signature -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] why is '01' == '1.'?
At 16:33 15/12/2005, Greg Beaver wrote: Stefan Walk wrote: See http://bugs.php.net/bug.php?id=23110 It's definitely a gotcha, especially if you use switch(){}, as there is no way to do strict type checking there. Please reconsider the decision to leave this bug open in PHP, any unexpected behavior in an operator as fundamental as == is VERY dangerous, and if used improperly could lead to security holes (i.e. unexpectedly, input that does not match could match a strict filter based on ==) I understand the rationale behind loosely typed comparison, and use it myself, but this is beyond loosely typed, it is explicitly changing type in an irrational way, as it only applies in certain cases. Greg, A lot of thought has been put into the current behavior, which was decided upon probably around 8+ years ago. While I'm not positive we made the right decision back then (even though I think we did) - changing this behavior is completely out of the question. It's not a bug, it's a well-documented feature (strings that look like numbers behave like numbers), and changing it would effect an enormous amount of applications. In order to change such a fundamental behavior there have to be clear-cut compelling reasons, and no compelling reasons against - which is clearly not the case. Zeev -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: why is '01' == '1.'?
Don't forget that one fundamental aspect of PHP is, that it's a web language and thus receives most of its input from the web. Therefore it usually only gets strings as input. Consider ($_POST['intfield1'] == $_POST['intfield2']) Both variables would be strings. Still if someone would input '01' and '1.' you'd want this expression to return true. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: why is '01' == '1.'?
Don't forget that one fundamental aspect of PHP is, that it's a web language and thus receives most of its input from the web. Therefore it usually only gets strings as input. Consider ($_POST['intfield1'] == $_POST['intfield2']) Both variables would be strings. Still if someone would input '01' and '1.' you'd want this expression to return true. However, XForms will have numeric datatypes. :| http://www.w3.org/TR/2003/REC-xforms-20031014/slice5.html Bart -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] php 5.1.1 syntax errors
I think I know what this is due to. I have an autoloader in places for classes. It seems that when a class is autoloaded, no matter what you do, it won't bother throwing an error when it loads a class. It however just stops processing. FULL STOP. If the error is in the localfile, it works fine. runtime errors work fine. It seems to be pre-runtime errors, now I don't know if this is because of the way the autoloader works at run time as opposed to pre-runtime. I don't know. Anyhow. If anyone could enlighten me, it would be great. On Thu, 15 Dec 2005 15:45:47 +0100, Jochem Maas wrote internals, it may be a badly worded (and inappropriately directed) post BUT I can categorically say that php5+ does have problems with displaying errors under certain circumstances - you see nothing anywhere regardless of ini/log/display settings. I have had such issues since php.5.0.3beta, I have never been able to reproduce the issue in a simple script (certain degree of code complexity is required - in practice that means running a 'production' framework of some sort). examples of the sort of problems that cause NOTHING to be reported, NOTHING to be logged and NOTHING to be displayed: 1. failed require/require_once statements. 2. non-abstract class with abstract methods (as declared in a base class). 3. method signature incompatibilities. when faced with such an error (like I just spent another 2 hours figuring out a newly developed class was missing a method [no. 2] - not the first time!) the only recourse I have it to start at the first line of php that is run and write something like: die(WTF IS GOING ON!?!?! :-(); and then keep moving it a line or 2 down at a time (stepping into all/any include files, of which there are normally about 25-50) until I find the offending line/file (at which point I can try to figure out what is actually wrong). Daine Mamacos wrote: Is there any reason why the php 5.1.1 command processor does not report syntax errors despite all errors being on in the .ini file? Maybe I'm doing something stupid. mee too - wish I knew what it was. -- random signature -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- random signature -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] why is '01' == '1.'?
Greg Beaver wrote: Hi all, I realize that 1 == '01' and 1 == '1.', but why is this next code also bool(true)? ?php var_dump('1.' == '01'); ? That is pure logic... a == b and a == c implies by the rules of logic that b == c -- Hans avast! Antivirus: Outbound message clean. Virus Database (VPS): 0550-3, 15/12/2005 Tested on: 15/12/2005 18:19:04 avast! - copyright (c) 1988-2005 ALWIL Software. http://www.avast.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] why is '01' == '1.'?
No, this rule of logic can't be applied : 2 == true and true == 10, but 2 != 10 It all depends on the types of the compared values. Hans Melis wrote: a == b and a == c implies by the rules of logic that b == c -- Etienne Kneuss http://www.colder.ch/ [EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] php 5.1.1 syntax errors
Daine Mamacos wrote: I think I know what this is due to. I have an autoloader in places for classes. It seems that when a class is autoloaded, no matter what you do, it won't bother throwing an error when it loads a class. It however just stops processing. FULL STOP. If the error is in the localfile, it works fine. runtime errors work fine. It seems to be pre-runtime errors, now I don't know if this is because of the way the autoloader works at run time as opposed to pre-runtime. I have also been caught out with regard to __autoload() related issues; but I removed my __autoload() function from my project about 18 months ago. thats not to say the problem may not be related to __autoload(), but I can say that you don't need to be using it to have the describe issue rear its head. I don't know. Anyhow. If anyone could enlighten me, it would be great. ditto - I'd love to find out what it is that I (or maybe the engine?) am/is doing wrong. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] why is '01' == '1.'?
actually, you're right in that (colder.ch) since what happens here is a conversion. This applies to all these 'logic cases' posted. When something is converted to something else, as part of a process, you can't state that the process returns unique results (meaning the result always points back to the same input), and as such you can't state a lot of various things posted in this thread. But this is all OT, and really should be moved off the list, or at least to the generals list. - tul colder.ch wrote: No, this rule of logic can't be applied : 2 == true and true == 10, but 2 != 10 It all depends on the types of the compared values. Hans Melis wrote: a == b and a == c implies by the rules of logic that b == c -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] why is '01' == '1.'?
Greg Beaver wrote: Hi all, I realize that 1 == '01' and 1 == '1.', but why is this next code also bool(true)? ?php var_dump('1.' == '01'); ? http://us3.php.net/manual/en/language.types.string.php#language.types.string.conversion Also, if you want strict type checking, try using === -- Carl -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: why is '01' == '1.'?
Bart de Boer wrote: However, XForms will have numeric datatypes. :| http://www.w3.org/TR/2003/REC-xforms-20031014/slice5.html And no one in their right mind uses them. Ilia -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php