I am including a function I created in a document. One of the conditional statements is supposed to exit if a referenced file isn't there.
The problem is, the first time the function exits, then the function is called again, it stops returning data.
Apparently, the function is no longer defined in the PHP engine. Is there an alternative to exit that will exit the conditional without undefining the function? I have tried "break" already. It caused other errors.
Here is the code:
<?php
function getdata($source, $url, $srchstr)
{
$file = @fopen("$url", "r");
if (!$file) {
echo "<p>Not found at $source\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
if (eregi("$srchstr", $line, $out)) {
$data = strip_tags("$out[1]");
return "$data from $source <br>";
break;
}
}
fclose($file);
}
?>