I recently started learning PHP, and I am having some problems with it. Look at this code:
The problem is that the code inside the function generated an error about users.txt being unreadable, while the code outside the function (which does the same thing) does not generate a problem at all! users.txt is a file in the same directory as the file that contains this php code, and I am very sure I have given it the correct permissions to be readable and writable through OS X (I have installed a PHP server on my machine using XAMPP).
Can anyone help me with this?
Code:
$clients = array();
$userFile = './users.txt';
if (is_readable($userFile) == false){
print "it still is not readable";
}
get_clients($clients, $userFile);
function get_clients(&$clientArr, $fileName){
if(is_readable($filename) == true){
$fp = fopen($fileName, "r");
}
else
{
print 'error. file is not readable';
}
}
Can anyone help me with this?