file-get-contents

How to get file content with a proper utf-8 encoding using file_get_contents?

走远了吗. 提交于 2019-12-13 10:25:49
问题 I need to get content of the remote file in utf-8 encoding. The file in in utf-8. When I display that file on screen, it has proper encoding: http://www.parfumeriafox.sk/source_file.html (notice the ň and č characters, for example, these are alright). When I run this code: <?php $url = 'http://parfumeriafox.sk/source_file.html'; $csv = file_get_contents_utf8($url); header('Content-type: text/html; charset=utf-8'); print $csv; function file_get_contents_utf8($fn) { $content = file_get_contents

How can I extract the required data from a page with JSON it's source? [closed]

谁说胖子不能爱 提交于 2019-12-13 09:14:59
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . For example, here is a QR Image: Source This API decodes the QR and outputs it's content which is "HelloWorld" in this case. How can I use file_get_contents() or a similar function to fetch the required data. 回答1: Actually is is possible to use file_get_contents() to access it. ( tested AND working

file_put_contents(): Filename cannot be empty

你。 提交于 2019-12-13 08:15:11
问题 I'm trying to add a cache mechanism to my Disqus API function: <?php ini_set('display_errors', 'on'); $key="MY_PUBLIC_KEY"; $forum="MY_FORUM"; $limit = '5'; $endpoint = 'http://disqus.com/api/3.0/posts/list.json?api_key='.urlencode($key).'&forum='.$forum.'&limit='.$limit.'&related=thread'; $cache_disqus = '/cache_path/file.json'; $j=0; listposts($endpoint,$j); function listposts($endpoint,$j) { // Standard CURL $session = curl_init($endpoint); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);

Calculate the total sum for each category from a text file

馋奶兔 提交于 2019-12-13 07:55:25
问题 I have a text file there I store all the data like this: dept|test-1|365|0 dept|test-2|134|0 expense|test-3|4387|0 expense|test-4|105|0 How can I get the sum of each category for all the transaction within that category? In this example, the category dept will have a total sum of 499 and the category expense will have a total sum of 4'492 . But how can I do this within PHP? Here's my current code: function do_maths($expression) { eval('$o = ' . preg_replace('/[^0-9\+\-\*\/\(\)\.]/', '',

PHP to read & parse big sized file? [closed]

白昼怎懂夜的黑 提交于 2019-12-13 03:56:11
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am about to read a text file sized 200Mb and then edit something inside and then to save it back. But i'm having errors. So: Which exact settings should be modified in php? Also what file reading method is the

PHP file_get_contents('php://input') very slow

隐身守侯 提交于 2019-12-13 02:38:58
问题 I have a complex PHP application that uses an ESB model built with Zend Framework v1.x. Performance has become an issue, and now I know why: reading the php://input stream is consistently taking almost exactly 10 seconds. Here is a snippet from an XDebug trace log: 0.3985 6935880 -> Zend_Controller_Request_Http->getRawBody() /var/www/vas/Adapters/Database/application/controllers/AdapterController.php:473 0.3985 6936104 -> file_get_contents() /usr/share/php/ZendFramework-1.12.0/library/Zend

simplehtmldom - SSL operation failed with code 1. OpenSSL Error messages

北城余情 提交于 2019-12-13 00:55:19
问题 I'm using http://simplehtmldom.sourceforge.net/ and file_get_contents() in my webApp. The file_get_contents() work fine on localhost. But when upload webApp on server(Windows server 2012 r2) i get this error. How to fix this error? > Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in E:\cfnic.com\includes\class\PHP_Simple_HTML_DOM_Parser.php on line 75 Warning: file_get

file_get_contents() “failed to open stream: Network is unreachable” error on valid link

余生颓废 提交于 2019-12-12 23:13:11
问题 There's an extremely simple example of using Youtube API in php that somehow fails to work in my case, and I couldn't find a definitive solution for. I desire to use the Youtube API without any wrapper, by myself, to get data of videos. The following search:list query works perfectly when I try accessing it from within by browser (as a link), but in php, I get that error when I try the same. $apikey_YT = <my API key>; $ytrequrl = "https://www.googleapis.com/youtube/v3/search?". "part=snippet"

file_get_contents vs cUrl. Which is more relevant and secure?

不问归期 提交于 2019-12-12 22:19:28
问题 Which would be more appropriate in terms of security? In case of file_get_contents(), if any error occurs, it displays the url being called in the error msg which may be vulnerable. 回答1: I think curl is more secure because if you're working with remote file with file_get_contents() you need to enable ‘allow_url_fopen’ reference : http://25labs.com/alternative-for-file_get_contents-using-curl/ http://phpsec.org/projects/phpsecinfo/tests/allow_url_fopen.html And continuing discussion from the

PHP - Retrieve Facebook image in Google Compute Engine

左心房为你撑大大i 提交于 2019-12-12 18:18:14
问题 I've tried to retrieve the image data of my Facebook profile picture, using both file_get_contents and curl. The problem occurs on my Google compute engine instance, while on any other server (localhost - mamp, AWS) the script works fine. An example for one of the scripts I was using <?php var_dump( json_decode( file_get_contents("https://graph.facebook.com/_FACEBOOK_ID_/picture?width=720&height=720") ) ); Please keep in mind that I've tried using the parameter redirect=false , and accessing