Re: Comparing Strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nils Holland wrote:
Hi folks,

well, I have a really dumb question:

I have the following script at http://www.tisys.org/misc/test.php:

<?php
echo $_GET['license'];
?>

Now I call it like this:

http://www.tisys.org/misc/test.php?license=070177016081137173166041245224242038105254210007183127207103162117160180165221170166096217228128

And in fact, it echos the whole, long GET-string!

Now i have the following script a tttp://www.tisys.org/misc/ol_license.php:

<?php
if ($_GET['license'] == "070177016081137173166041245224242038105254210007183127207103162117160180165221170166096217228128")
{
    echo '1';
} else {
    echo '0';
}
?>

I launch it like:

http://www.tisys.org/misc/ol_license.php?license=070177016081137173166041245224242038105254210007183127207103162117160180165221170166096217228128

And it returns a 1, which means: The strings match. Now I call it like

http://www.tisys.org/misc/ol_license.php?license=170177016081137173166041245224242038105254210007183127207103162117160180165221170166096217228128

that is, I have changed the first number of my GET-String from a 0 to a 1 and indeed, the script returns 0, meaning: The scripts don't match. *HOWEVER*, no I call the script like:

http://www.tisys.org/misc/test.php?license=070177016081137173166041245224242038105254210007183127207103162117160180165221170166096217228129

that is, I have changed the last number of the GET-String from an 8 to a 9, and interestingly, it returns 1 this time, which means the strings do match, which, however, they don't.

My guess is that PHP only sees / compares the strings up to a certain position. Is this possible? And if so, is there any way around this, so that my whole string is seen?

Greetings and thanks in advance,
Nils

Maybe it's interpreting something as a number somewhere. Did you try using === instead of == for your comparisons?

Regards, Adam Zey.

PS: Why is your license key so insanely long, and why doesn't it use alphanumeric characters to reduce the length?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux