<?php
function hit_count()
{
$ip_address = $_SERVER['REMOTE_ADDR'];
$ip_file = file('ip.txt'); //file() function stores each line of that text file in form of an array.
foreach($ip_file as $ip)
{
//echo $ip.', ';
$ip_single = trim($ip); //space is there at the end of each line so you can use trim to remove the white space.
if($ip_address == $ip_single)
{
$found = true;
break;
}else{$found = false;}
}
if($found == true){
echo 'found';
} else {echo 'not found';}
}
?>
Error is:
Notice: Undefined variable: found in C:\xampp\htdocs\series\72Hit counter\uniqueHitcounter\count.php on line 18
its in this line if($found == true)
is either true or false and its defined inside the same function.
I am including and calling this function from a separate file.