1

I have this part of PHP code:

<?php
$dns = file_get_contents('./dns.txt');

$dns2 = 'serverquery://name:[email protected]:10011/?server_port=9987&use_offline_as_virtual=1&no_query_clients=1';

$dns3 = 'serverquery://name:pass@' . $dns . ':10011/?server_port=9987&use_offline_as_virtual=1&no_query_clients=1';

if (strcmp($dns2, $dns3) !== 0) {
    echo '$dns2 is not equal to $dns3';
}

echo '<br><br>DNS<br>';
print $dns;
echo '<br><br>DNS2<br>';
print $dns2;
echo '<br><br>DNS3<br>';
print $dns3;
echo '<br><br><br>';

?>

file dns.txt contais only text example.com without any space at the begin or at the end

when I run this code, the result is:

$dns2 is not equal to $dns3

DNS
example.com

DNS2
serverquery://name:[email protected]:10011/?server_port=9987&use_offline_as_virtual=1&no_query_clients=1

DNS3
serverquery://name:pass@example.com:10011/?server_port=9987&use_offline_as_virtual=1&no_query_clients=1

i'm trying to create serverquery for TeamSpeak 3 server and it only works if I use $dns2 and I want it to work with $dns3

so my question is: why $dns2 is not equal to $dns3 ?

can you please help me ?

5
  • 1
    Use var_dump() to verify the contents of the file and see whether it really contains what you think it does Commented Jun 14, 2014 at 17:29
  • you are right... but why they are not the same? DNS:(length=14) DNS2:(length=103) DNS3:(length=106) Commented Jun 14, 2014 at 17:32
  • Also look at the actual output and you will have your answer. Commented Jun 14, 2014 at 17:33
  • im trying but i cant see any diference :/ string 'serverquery://name:[email protected]:10011/?server_port=9987&use_offline_as_virtual=1&no_query_clients=1' (length=103) and string 'serverquery://name:[email protected]:10011/?server_port=9987&use_offline_as_virtual=1&no_query_clients=1' (length=106) Commented Jun 14, 2014 at 17:37
  • If you upload you file here and @fredirik is correct you will see three leading characters hexdump.pieterhordijk.com Commented Jun 14, 2014 at 17:39

1 Answer 1

1

You have some hidden characters in your dns.txt file. Make sure it is encoded UTF-8 without BOM.

The UTF-8 BOM is a sequence of bytes (EF BB BF), hence the overhead of three characters.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.