Bug #75980 [Com]: greater or equal (formerly >=) is missinterpreted

From: Date: Mon, 19 Feb 2018 13:01:36 +0000
Subject: Bug #75980 [Com]: greater or equal (formerly >=) is missinterpreted
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214028@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75980&edit=1 ID: 75980 Comment by: rolf at rolfjentsch dot de Reported by: rolf at rolfjentsch dot de Summary: greater or equal (formerly >=) is missinterpreted Status: Open Type: Bug Package: Scripting Engine problem Operating System: windows 10 xamp PHP Version: 7.2.2 Block user comment: N Private report: N New Comment: Thank you for your hint with - if(strpos($_SERVER['SERVER_ADDR'],"192.168.10") >= 0) + if(strpos($_SERVER['SERVER_ADDR'],"192.168.10") !== false) But a if(strpos($_SERVER['SERVER_ADDR'],"192.168.10") !< 0) still does what it does in previous versions Wbr Rolf Jentsch Previous Comments: ------------------------------------------------------------------------ [2018-02-19 13:00:44] spam2 at rhsoft dot net > made it possible to have a <? ?> or <?php ?> anywhere in the source document frankly you mix completly different topics to start with <? ?> aka short-open-tags should not be used for many years <?=?> got an exception indepdendent if short-open is allowed in config > a normal if statement with a ">=" compare opertor finishes interpreting php THIS IS NOT TRUE - PERIOD - otherwise the sample with you broken code won't reach the echo statement at all and when you replace ">= 0" with a proper !== false it even works as intended [harry@srv-rhsoft:/downloads]$ php test.php http://qnap/piwik/ [harry@srv-rhsoft:/downloads]$ cat test.php <?php $_SERVER['SERVER_ADDR'] = '192.168.196.0'; if (isset($_SERVER['SERVER_ADDR'])) { if (strpos($_SERVER['SERVER_ADDR'],"192.168.10") >= 0) { $where="http://qnap/piwik/"; } else { $where="https://someurlhere/"; } } else $where="https://someurlhere/"; echo $where, "\n"; ------------------------------------------------------------------------ [2018-02-19 12:54:59] rolf at rolfjentsch dot de Formerly versions of php (like 5.6) made it possible to have a <? ?> or <?php ?> anywhere in the source document. Now with php 7 (actually tested on 7.2.2) a normal if statement with a ">=" compare opertor finishes interpreting php. (As it would be expected when i had written "?>" ) On top - dont know if related to the above a function defined inside the <html> <body> tag is not recognized as defined. aamof i defined a function there definetly before its first usage and it does not work. moving it before the <html> <body> tag solves the problem ------------------------------------------------------------------------ [2018-02-19 12:43:53] spam2 at rhsoft dot net it would be a good start to write proper code and then it even works >= 0 when comparing the boolean 'false' triggers implict type-casting and false weak >compared to 0 is the same as int 0 when the string starts with needle that this worked in some arbitary PHP version was just by luck - if(strpos($_SERVER['SERVER_ADDR'],"192.168.10") >= 0) + if(strpos($_SERVER['SERVER_ADDR'],"192.168.10") !== false) ------------------------------------------------------------------------ [2018-02-19 12:41:36] rolf at rolfjentsch dot de Processing a .php document is done wrong imho. When a statement like "if (strpos($_SERVER['SERVER_ADDR'],"192.168.10") >= 0)" is proccessed it does not compare but finishes to interpret (which would be fine if there is a "?>") but the compare option ">=" finishes interpretation of the source and echoes in the above example "= 0)" This appplies to all php 7 versions i have tested so far either on ubuntu or on xammp. ------------------------------------------------------------------------ [2018-02-19 12:18:30] peehaa@php.net It's not clear at all what this bug report is trying to... report. Please provide clear information regarding the expected output, the actual output and a proper test case. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=75980 -- Edit this bug report at https://bugs.php.net/bug.php?id=75980&edit=1

« previous php.bugs (#214028) next »