Example 1
<?php function Piso() { $ip = '77.1.1.1.1'; $ip2 = $_SERVER['REMOTE_ADDR']; return ($ip == $ip2); } ?> Example 2
<?php function Piso() { $ip = fopen("bune.txt", "r"); $ip2 = $_SERVER['REMOTE_ADDR']; return ($ip == $ip2); } ?> I want to read IP address from file bune.txt. If i read it == doesnt work. If i put ip address like example one, it works. But i need example 2 to work. Example two doesnt work, but i dont know how to read it to can $ip == $ip2. Thanks.
fopendoes not read file contents. It just sets you up for reading. If you want an one-stop-shop for reading, usefile_get_contentsinstead. As an aside, you should have triedvar_dump($ip)immediately after you got your first unexpected result.