Search code examples
file-get-contents

file_get_contents() working on localhost but not working on online server


$result = file_get_contents(ADMIN_URL.'/content/'.$name.'.php');
if($result){
  echo "YES";exit;
}else{
  echo "NO";exit;
}

Output is NO, where ADMIN_URL is "turkjammat.com/demo/administrator/" and $name is mardumshumari which makes url in file_get_contents() funciton "turkjammat.com/demo/administrator/content/mardumshumari.php" and the file is there in above url, this code is working fine in my local xamp server but when i deploying it on my hosting server its not working. plese help some body. Thanks


Solution

  • Your hosting server typically does NOT have the same folder hierarchy for user home directories as your local server.

    Run php_info() on your hosting server to find out what the correct path is. Look for DOCUMENT_ROOT in the Environment section.

    A simple phpinfo.php file looks like this:

    <?php
     phpinfo();
    ?>