2017-03-09 1 views
5

언제 PHP 동작이 변경 되었습니까?file_get_contents() : 스트림이 탐색을 지원하지 않습니다 /이 문제에 대한 PHP 동작이 변경된시기는 언제입니까?

PHP 버전은 무엇입니까?


경고 : file_get_contents() : 스트림이 /simple_html_dom.php

경고에 노력을 지원하지 않습니다 : file_get_contents() : /simple_html_dom에 위치 추구 -1 스트림에 실패 에 .php


include('parser/simple_html_dom.php'); 
$url = "https://en.wikipedia.org/wiki/Stack_Overflow"; 
$html = file_get_html($url); 
if ($html !== false) { 
    foreach($html->find('div#mw-content-text') as $item){ 
    $item->plaintext; 
    } 
} 
+2

PHP 7.1에서이 ocurrs에 $offset in file simple_html_dom.php을 제거 할 수 있지만 7.0의 D 5.6 잘 작동. – Jorny

답변

2

참조 file_get_contents(): stream does not support seeking PHP

원격 파일로 작업하고 있습니다. 검색은 로컬 파일에만 지원됩니다.

file_get_html을 사용하기 전에 파일을 로컬 파일 시스템에 복사해야합니다. 그것은 localhost에서 잘 작동해야합니다.

+0

PHP 비헤이비어가 변경되지 않았습니까? 이 사양은 과거와 변경되지 않습니까? – re1

+1

changelog http://php.net/manual/en/function.file-get-contents.php에 따르면 원격 파일을 찾는 것과 관련된 변경 사항이 없습니다. 그래서 이전에 찾기가 괜찮은 로컬 파일 (또는 원격 파일의 작은 범위에서도 작업 할 수있는 운이 좋았던 곳)에 대해서만 이전에 작업했다고 가정합니다. –

+0

감사합니다. > 때로는 원격 파일의 작은 범위에서 작업 할 수도 있습니다. doc – re1

34

한 시스템에서 다른 시스템으로 옮길 때 내 페이지에서 동일한 문제가 발생하여 오프셋 참조 (didn; t는 더 이상 문제가되지 않음)를 제거하여 simple_html_dom 파일을 변경할 수있었습니다. simple_html 라인 (75)에

는 : 없음 내 페이지가 잘 작동

$contents = file_get_contents($url, $use_include_path, $context); 

, 무엇에 대한 책임을 복용하지가 중단되지 :

$contents = file_get_contents($url, $use_include_path, $context, $offset); 

내가 오프셋 $에 대한 참조를 제거!

+0

간단하면서도 훌륭합니다! 천재! –

+0

오늘 저장되었습니다. Genius. –

+0

당신은 절대적으로 최고입니다 –

10

변경

function file_get_html(..., $offset = -1,...) 

simple_html_dom.php 파일에서

+0

작동하지만 왜 작동합니까? – Andrew

3

simple_html_dom.php에서

function file_get_html(..., $offset = 0,...) 

에 :) $offset를 검색하고 제거를-는 라인 (75) 및 (76)에 있어야합니다 모든 것이 잘 작동 할 것입니다.

0

오류

Warning: file_get_contents(): stream does not support seeking in https:\kenhlaptrinh.net\tctt\simple_html_dom.php on line 76 

Warning: file_get_contents(): Failed to seek to position -1 in the stream in https:\kenhlaptrinh.net\tctt\ssimple_html_dom.php on line 76 

그리고

나는 라인 75

+0

이것은 실제로 질문에 대답하지 않습니다. 다른 질문이있는 경우 [질문하기] (https://stackoverflow.com/questions/ask)를 클릭하여 질문 할 수 있습니다. [평판] (https://stackoverflow.com/help/privileges/set-bounties)을 충분히 확보하면 [현상금 추가] (https://stackoverflow.com/help/privileges/set-bounties)를 통해이 질문에 더 집중할 수 있습니다. 평판). - [From Review] (리뷰/저품절 게시물/18294233) –