[Phpmyadmin-devel] (PMA_SQP_typeCheck) operator "===" and PHP 3

I remember we discussed this, but did we find a good solution? There is a "===" operator in sqlparser.lib.php3. Marc

On Tue, Feb 04, 2003 at 08:55:24AM -0500, Marc Delisle wrote:
I remember we discussed this, but did we find a good solution?
There is a "===" operator in sqlparser.lib.php3. I just never got around to trying your solution, since I don't have access to a PHP3 installation.
-- Robin Hugh Johnson E-Mail : robbat2@orbis-terrarum.net Home Page : http://www.orbis-terrarum.net/?l=people.robbat2 ICQ# : 30269588 or 41961639 GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85

Robin Johnson wrote:
On Tue, Feb 04, 2003 at 08:55:24AM -0500, Marc Delisle wrote:
I remember we discussed this, but did we find a good solution?
There is a "===" operator in sqlparser.lib.php3.
I just never got around to trying your solution, since I don't have access to a PHP3 installation.
I don't remember what was my solution. But maybe the person who has the problem could try the solution if you can feed it in the thread: http://sourceforge.net/forum/forum.php?thread_id=807081&forum_id=72909 Marc

Hi Robin, Marc & list, -----Original Message----- From: Marc Delisle
I remember we discussed this, but did we find a good solution?
There is a "===" operator in sqlparser.lib.php3.
I just never got around to trying your solution, since I don't have access to a PHP3 installation.
I don't remember what was my solution.
Shouldn't it be possible to replace ($a === $b) by the following expression? ($a == $b && gettype($a) == gettype($b)) Alexander M. Turek <alex@bugfixes.info> +-----------------------------+ | The phpMyAdmin Project | | http://www.phpmyadmin.net | | rabus@users.sourceforge.net | +-----------------------------+ | [bugfixes.info] | | http://www.bugfixes.info | | rabus@bugfixes.info | +-----------------------------+

Rabus wrote:
Hi Robin, Marc & list,
-----Original Message----- From: Marc Delisle
I remember we discussed this, but did we find a good solution?
There is a "===" operator in sqlparser.lib.php3.
I just never got around to trying your solution, since I don't have access to a PHP3 installation.
I don't remember what was my solution.
Shouldn't it be possible to replace
($a === $b)
by the following expression?
($a == $b && gettype($a) == gettype($b))
Alexander M. Turek <alex@bugfixes.info>
gettype( ) works on variables, but the case we have is: if(strpos($whatWeWant, $typeSeperator) === FALSE) { I don't know if it works on expressions and constants. Anyway, looking at the code, we usually workaround this strpos problem with the "append a blank" trick: if (strpos(' ' . $goto, 'tbl_properties') == 1) { Marc

-----Original Message----- From: Marc Delisle [mailto:DelislMa@CollegeSherbrooke.qc.ca]
gettype( ) works on variables, but the case we have is: if(strpos($whatWeWant, $typeSeperator) === FALSE) {
I don't know if it works on expressions and constants.
Anyway, looking at the code, we usually workaround this strpos problem with the "append a blank" trick:
if (strpos(' ' . $goto, 'tbl_properties') == 1) {
Marc
Of course, it does. gettype() checks the type of the expression. A variable is also an expression, just like a function call, a mathmatic operation or whatever. I'm taking your example and using my workaround: if (strpos($whatWeWant, $typeSeperator) == FALSE && gettype(strpos($whatWeWant, $typeSeperator)) == gettype(FALSE)) { Of course, we can make this a bit shorter: $tmp = strpos($whatWeWant, $typeSeperator); if (!$tmp && gettype($tmp) == 'boolean') { But our usual workaround for the strpos problem is this one: if (!strpos(' ' . $whatWeWant, $typeSeperator)) { Your code above appears incorrect to me because we want to have the case that the needle string does not appear in the haystack string, don't we? So 1 is wrong, it has to be 0 or FALSE (doesn't matter since 0 == FALSE :o) ). Alexander M. Turek <alex@bugfixes.info> +-----------------------------+ | The phpMyAdmin Project | | http://www.phpmyadmin.net | | rabus@users.sourceforge.net | +-----------------------------+ | [bugfixes.info] | | http://www.bugfixes.info | | rabus@bugfixes.info | +-----------------------------+

Rabus wrote:
-----Original Message----- From: Marc Delisle [mailto:DelislMa@CollegeSherbrooke.qc.ca]
gettype( ) works on variables, but the case we have is: if(strpos($whatWeWant, $typeSeperator) === FALSE) {
I don't know if it works on expressions and constants.
Anyway, looking at the code, we usually workaround this strpos problem with the "append a blank" trick:
if (strpos(' ' . $goto, 'tbl_properties') == 1) {
Marc
Of course, it does. gettype() checks the type of the expression. A variable is also an expression, just like a function call, a mathmatic operation or whatever. I'm taking your example and using my workaround:
if (strpos($whatWeWant, $typeSeperator) == FALSE && gettype(strpos($whatWeWant, $typeSeperator)) == gettype(FALSE)) {
Of course, we can make this a bit shorter:
$tmp = strpos($whatWeWant, $typeSeperator); if (!$tmp && gettype($tmp) == 'boolean') {
But our usual workaround for the strpos problem is this one:
if (!strpos(' ' . $whatWeWant, $typeSeperator)) {
Your code above appears incorrect to me because we want to have the case that the needle string does not appear in the haystack string, don't we? So 1 is wrong, it has to be 0 or FALSE (doesn't matter since 0 == FALSE :o) ).
Alexander M. Turek <alex@bugfixes.info>
Ok Alexander. I have merged this, and usually we should use \xff instead of a blank because chances are lower that we find a real \xff: if(!strpos("\xff" . $whatWeWant, $typeSeperator)) { Marc
participants (4)
-
Marc Delisle
-
Marc Delisle
-
Rabus
-
Robin Johnson