$xml_file = file_get_contents(SITE_PATH . 'cms/data.php');
The problem is that a server has URL file-access disabled. I cannot enable it, its a hosting thing.
So the question is this. The data.php
file generates xml code.
How can I execute this and get the xml data without doing the above method?
Is it possible?
file_get_contents() is slightly faster than cURL.
The file_get_contents() reads a file into a string. This function is the preferred way to read the contents of a file into a string. It will use memory mapping techniques, if this is supported by the server, to enhance performance.
They both read an entire file, but file reads the file into an array, while file_get_contents reads it into a string.
Short answer: No. file_get_contents is basically just a shortcut for fopen, fread, fclose etc - so I imagine opening a file pointer and freading it isn't cached.
Use cURL. This function is an alternative to file_get_contents
.
function url_get_contents ($Url) { if (!function_exists('curl_init')){ die('CURL is not installed!'); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); curl_close($ch); return $output; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With