strpos misbehaving in script
Posted: 16 Oct 2021 17:02
I'm debugging a script that doesn't do what it is supposed to do and while doing so, I came across a surprising result from
I have added some logging and with that, the surprise comes from this code:
The variable $rep contains a log, and its value for the critical part is this:
Yet, if I take exactly that code, prefix an
So I added some more code to see if that really misbehaves as it seems to do:Nope, that gives the correct answer:
So, could it be that the failing code "sees" different content than it prints? Don't know if that is even possible, but I would expected that in this case it would show a "surprising"
gave this:
that seems to be correct. So I have no idea what else I could check and how I could sort out this problem...
strpos
that I can't understand - maybe I have a fundamental misunderstanding somewhere or maybe something else is wrong. I feel totally clueless atm and would appreciate another set of eyes (and braincells) looking at this.I have added some logging and with that, the surprise comes from this code:
Code: Select all
$c1=-1
$c = strpos($currh,">",$c1);
$rep .= "strpos(" . quote($currh) . "," . quote(">") . ",$c1)=$c<crlf>";
Code: Select all
strpos("Apps>FinePrint",">",-1)=0
echo
and copy it into the address bar and execute it, it returns 4 - as expected.So I added some more code to see if that really misbehaves as it seems to do:
Code: Select all
$currh = "Apps>FinePrint";
$c = strpos($currh,">",$c1);
$rep = "strpos(" . quote($currh) . "," . quote(">") . ",$c1)=$c<crlf>";
Code: Select all
strpos("Apps>FinePrint",">",-1)=4
strlen
... Let's see:
Code: Select all
$rep .= "strpos(" . quote($currh) . "," . quote(">") . ",$c1)=$c<crlf>strlen(currh)=" . strlen($currh) . <crlf>;
Code: Select all
strpos("Apps>FinePrint",">",-1)=0
len(currh)=14