개발! 딱 깔끔하고 센스있게!

PHP : file_get_contents ($ loc) 실패 본문

개발 스크랩 메모/PHP

PHP : file_get_contents ($ loc) 실패

렉사이 2020. 12. 14. 02:36

나는 방금 로컬 호스트를 원격 서버로 옮겨서 나의 일부 스크립트가 중단되었다.

가장 중요한 것은 file u get conents () 다른 스크립트에서 json 값을 얻는 것이다.

php 버전은 5.2.4.URL 열기 허용

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/2009/functions/functions.products.php on line 5

Warning: file_get_contents(http://data.example.com/new-data.php) [function.file-get-contents]: failed to open stream: Success in /var/www/html/2009/functions/functions.products.php on line 5

스크립트 실행 위치: http: / www.example.com함수에 전달된 위치는 http://data.example.com /new -data.php

주의: 같은 도메인 이름, 다른 서버 두 개 있습니다.

function getData() { $location = "http://data.mysite.com/new-data.php"; $contents = file_get_contents($location); $jsonVars = json_decode($contents); return $jsonVars } 

대답

Name or service not known

DNS 끊기.당신은 기계에 있는 shell ping data.my site.com (가설 당신은 shell)?

잠시 고정된 IP 주소로 data.my site.com 교체를 시도합니다.

Comments