PHP never testing true for file_exists while evaluating array value
<p>My problem is I set an array value to the name of a server as follow:</p>

<pre><code>$appserver[$i]=`grep $ip[2] /etc/hosts |awk '{print $2}'`;
</code></pre>

<p>Later I do a test to see if the server is up or not (using a wget).
If the test fails I keep track of that server being down by creating a file with that
name using touch:</p>

<pre><code>$touch=`touch /home/steve/data/$appserver[$i];
</code></pre>

<p>The file gets created successfully.
Later when I go to test whether or not the file exists it never evaluates to true.</p>

<pre><code>if(file_exists('/home/steve/data/$appserver[$i])) {
</code></pre>

<p>I have tried several different things including creating a new variable for 
$appserver[$i] and testing against it, which also does not work:</p>

<p>I am running php 5.1.6 on RHEL 5.</p>

<p>Here is the full code:</p>

<pre><code>  $appserver[$i]=`grep $ip[2] /etc/hosts |awk '{print $2}'`;
  echo "appserver[i] = $appserver[$i]\n";
   $get=`wget $key-&gt;url 2&gt; /dev/null`;
   if(file_exists('/home/user/Start')) {
            $color[$i]="green";
            $rm=`rm -rf /home/user/Start`;
    }
    else {
            $color[$i]="red";
            if($hostname=="xxxxx" ) {
                    **if(file_exists('/home/user/data/$appserver[$i]))**  {**
                        echo "do nothing appserver file exists\n";
                        $touch=`touch /home/steve/data/notmailed`;
                        }
                    else {
                    echo "No app file mailed alert\n";
                    $touch=`touch /home/user/data/$appserver[$i]`;
                    }
            }
    }
</code></pre>

<p>Thank you.</p>
