Someone wanna tell me why this doesn't work?
Fatal error: Call to a member function on a non-object in /home/belikeid/public_html/index2.php on line 14
Line 14 is this line:
while(($file = $thisdir->read()) !== false)
out of this function:
function printdirectory($thisdir){
$numfiles=0;
$filelinkslength=0;
$linksymbol="#";
while(($file = $thisdir->read()) !== false)
{
$numfiles++;
if ($numfiles!=2){
echo "<A href=".$thisdir.$file." title=".$file.">".$linksymbol."</a>";
$filelinkslength++;
}
if ($filelinkslength==5){
echo "<br>";
$filelinkslength=0;
}
}
return;
}
So why does while(($file = $thisdir->read()) !== false) have issues executing inside of this function, but if I stick it in the code without using a function, it has no issues?
Line 14 is this line:
while(($file = $thisdir->read()) !== false)
out of this function:
function printdirectory($thisdir){
$numfiles=0;
$filelinkslength=0;
$linksymbol="#";
while(($file = $thisdir->read()) !== false)
{
$numfiles++;
if ($numfiles!=2){
echo "<A href=".$thisdir.$file." title=".$file.">".$linksymbol."</a>";
$filelinkslength++;
}
if ($filelinkslength==5){
echo "<br>";
$filelinkslength=0;
}
}
return;
}
So why does while(($file = $thisdir->read()) !== false) have issues executing inside of this function, but if I stick it in the code without using a function, it has no issues?
