In the following loop, at the end, the method debugNotes() is printing
out some notes for me to read, so I can figure out what is going on in
my script. Where I try to print out the value of the variable $noFile,
it is print "1" instead of "true". Why does it do this?
The loop is failing to run a second time, for reasons I can not
fathom. debugNotes tells me that the count of $dirArray is 10, and the
file hasn't been found yet, so I would expect the loop to keep
looping.
Why?
for ($i=0; $i < count($dirArray ) && $noFile == true; $i++) {
$noFile = false;
$dir = $dirArray[$i];
$tryThisDir = $this->pathToNeededFi les.$dir;
// 11-10-03 - first we try to find the file using the prefix
$fileNameToTry = $prefix.$name;
$tryThisFile = $tryThisDir.$fi leNameToTry;
$theFileIsLoade d = @include($tryTh isFile);
if (!$theFileIsLoa ded) {
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
// 11-10-03 - then we try it with ".php" at the end
if (!$theFileIsLoa ded) {
$tryThisFile = $tryThisDir.$fi leNameToTry.".p hp";
$theFileIsLoade d = @include($tryTh isFile);
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
// 11-10-03 - if that fails, then we try to find the file without
using the prefix.
if (!$theFileIsLoa ded) {
$tryThisFile = $tryThisDir.$na me;
$theFileIsLoade d = @include($tryTh isFile);
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
if (!$theFileIsLoa ded) {
$tryThisFile = $tryThisFile.". php";
$theFileIsLoade d = @include($tryTh isFile);
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
if (!$theFileIsLoa ded) {
$noFile = true;
$num = count($dirArray );
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we end $i loop without finding the file we wanted.
We expect to do a total of $num loops, maximum. Our variable noFile
should be registered 'true' at this point. It's value is: $noFile .");
}
}
out some notes for me to read, so I can figure out what is going on in
my script. Where I try to print out the value of the variable $noFile,
it is print "1" instead of "true". Why does it do this?
The loop is failing to run a second time, for reasons I can not
fathom. debugNotes tells me that the count of $dirArray is 10, and the
file hasn't been found yet, so I would expect the loop to keep
looping.
Why?
for ($i=0; $i < count($dirArray ) && $noFile == true; $i++) {
$noFile = false;
$dir = $dirArray[$i];
$tryThisDir = $this->pathToNeededFi les.$dir;
// 11-10-03 - first we try to find the file using the prefix
$fileNameToTry = $prefix.$name;
$tryThisFile = $tryThisDir.$fi leNameToTry;
$theFileIsLoade d = @include($tryTh isFile);
if (!$theFileIsLoa ded) {
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
// 11-10-03 - then we try it with ".php" at the end
if (!$theFileIsLoa ded) {
$tryThisFile = $tryThisDir.$fi leNameToTry.".p hp";
$theFileIsLoade d = @include($tryTh isFile);
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
// 11-10-03 - if that fails, then we try to find the file without
using the prefix.
if (!$theFileIsLoa ded) {
$tryThisFile = $tryThisDir.$na me;
$theFileIsLoade d = @include($tryTh isFile);
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
if (!$theFileIsLoa ded) {
$tryThisFile = $tryThisFile.". php";
$theFileIsLoade d = @include($tryTh isFile);
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we tried to include $tryThisFile but we did not
find it.");
}
if (!$theFileIsLoa ded) {
$noFile = true;
$num = count($dirArray );
$this->debugNotes(" $i loop. In getArrangement( ), in the class
McControllerFor All, we end $i loop without finding the file we wanted.
We expect to do a total of $num loops, maximum. Our variable noFile
should be registered 'true' at this point. It's value is: $noFile .");
}
}
Comment