Problem with strange variable value
Posted: Tue Aug 11, 2009 3:18 pm
Hi,
I've been struggling with this problem for some hours and I can't find a solution. I usually don't ask for help on forums but this time I just feel helpless... so I would really appreciate your suggestions.
I'm working with a CMS (MODx) and in one point I'm sending a document ID:
and in another place I'm receiving it:
I've written a function to test it's value:
Now we come to the strange place.
When I open different documents:
This is what I get (when invoking 'printStringCharacters' function):
I don't understand it. Why the string (display) value is proper and the characters' codes don't change?! Is it pointing to an object??? Why then it's showing that it's a 6-character long string? Why the string is not 3-character long?.
I tried to manually encode "147" number and what I could get is:
So it's not about encoding. What is it then?
It wouldn't bother me if not the SQL query which works with '147' for example but doesn't work with $cfg['atrId'].
Thanks,
Mateusz Sobczak
I've been struggling with this problem for some hours and I can't find a solution. I usually don't ask for help on forums but this time I just feel helpless... so I would really appreciate your suggestions.
I'm working with a CMS (MODx) and in one point I'm sending a document ID:
Code: Select all
[!anythingRating? &atrGrp=`Articles` &define=`1`!][!anythingRating? &atrGrp=`Articles` &atrId=`[*id*]`!]Code: Select all
$cfg['atrId'] = isset($atrId) ? $atrId : 0;Code: Select all
function printStringCharacters($str) {
print "string: [$str] ";
$c = strlen($str);
print '[';
for($i = 0; $i < $c; $i++) {
print ord(substr($str, $i, 1)).' ';
}
print "] ";
var_dump($str);
}When I open different documents:
Code: Select all
http://<my_domain>/147
http://<my_domain>/231
http://<my_domain>/232Code: Select all
string: [147] [91 42 105 100 42 93 ] string(6) "147"
string: [231] [91 42 105 100 42 93 ] string(6) "231"
string: [232] [91 42 105 100 42 93 ] string(6) "232"I tried to manually encode "147" number and what I could get is:
Code: Select all
string: [147] [49 52 55 ]
string: [?1?4?7] [0 49 0 52 0 55 ] (UTF-16)
string: [147] [49 52 55 ] (UTF-7)
string: [147] [49 52 55 ] (EUC-JP)
string: [147] [49 52 55 ] (SJIS)
string: [1?4?7?] [49 0 52 0 55 0 ] (UCS-2LE)
string: [147] [49 52 55 ] (JIS)
string: [147] [49 52 55 ] (eucjp-win)
string: [147] [49 52 55 ] (sjis-win)It wouldn't bother me if not the SQL query which works with '147' for example but doesn't work with $cfg['atrId'].
Thanks,
Mateusz Sobczak