file_get_contents( ) not working
Login to your server via ssh and type
sudo nano /etc/php5/apache2/php.ini //<<<< ubuntu/debian server, might differ for you
in the file, simply press "ctrl + w"
and type "allow_url_fopen"
and Return, most probably you will come to the explanation first, so repeat the search a couple of times. Now you can change the entry from
allow_url_fopen=0
to
allow_url_fopen=1
press "ctrl + x"
and confirm the file save with "y"
.
Then type
sudo service apache2 restart
This will restart apache so the new php.ini configuration can be loaded. After those steps, you should be able to use file_get_contents
externally.
SIDENOTE
If you can't find your php.ini file, you will find the path to the loaded php.ini file in the top section of your phpinfo()
file_get_contents not working with variable PHP
Follow @CBroe way. I'm used var_dump and see the length is different. After many checking I found the variable is hex code http://i132.photobucket.com/albums/q13/animalhelper2006/1376.jpg
Final I used html_entity_decode function and it working fine now.
$contents = file_get_contents(html_entity_decode($imageurl));
PHP : file_get_contents not working properly
Try the below code, this will make sure that you're stuff is properly URI encoded.
$params = [
'token' => $_GET['token'],
'agencyName' => $_GET['agency'],
'stopName' => $_GET['stopname']
];
$file = file_get_contents(sprintf("http://services.my511.org/Transit2.0/GetNextDeparturesByStopName.aspx?%s", http_build_query($params));
echo(json_encode(simplexml_load_string($file)));
Related Topics
PHP Sessions with Disabled Cookies, Does It Work
Finding the PHP File (At Run Time) Where a Class Was Defined
How to Export a SQL Table Without Access to the Server or PHPmyadmin
Setup Http Expires Headers Using PHP and Apache
PHP Function for Get All Mondays Within Date Range
Laravel - Using (:Any) Wildcard for All Routes
Relative Path Not Working in Cron PHP Script
Laravel Eloquent: How to Order Results of Related Models
Detecting Image Type from Base64 String in PHP
Having Problems While Try to Install Oauth with Pecl in Mamp on MAC Os Lion
Configure Multiple Databases in Zf2
How to Auto Call Function in PHP for Every Other Function Call
PHP Can't Connect to MySQL with Error 13 (But Command Line Can)
Custom Laravel Validation Messages