สอบถามการใช้ file_get_contents ครับ

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: สอบถามการใช้ file_get_contents ครับ

Re: สอบถามการใช้ file_get_contents ครับ

โดย na2b ltd., part » 12/03/2010 11:46 pm

มันมีอยู่ 2 แบบนะครับคือ

file_get_contents("http://test.php"); คงเอาไว้เรียกไฟล์นั้นมาเก็บ แ่ต่ถ้าจะเรียกค่า xml
คงต้องใช้ simplexml_load_file("ชื่อไฟล์"); มั่งครับ

:)

Re: สอบถามการใช้ file_get_contents ครับ

โดย darksoullest » 02/11/2009 2:33 pm

สามารถทำได้เเล้วนะครับ

Re: สอบถามการใช้ file_get_contents ครับ

โดย darksoullest » 27/10/2009 2:36 pm

ถามอีกนิดหนึ่งนะครับ ถ้าผมต้องการที่จะดึง ข้อมูล xml ที่อยู่ในรูปของไฟล์ php ผมจะต้องทำอย่างไรบ้างอะครับ
รบกวนด้วยครับ ขอบคุณครับ

Re: สอบถามการใช้ file_get_contents ครับ

โดย mindphp » 27/10/2009 2:14 pm

รูปแบบ file ที่ต้องการเปิดไม่ถูกต้องครับ.....

Re: สอบถามการใช้ file_get_contents ครับ

โดย darksoullest » 27/10/2009 2:05 pm

ไฟล์ที่ต้องการเปิด ก็คือ url ที่อยู่บน internet อะครับ คือผมต้องการดึง content มาจากนั้นจะนำมาตัดด้วย xml นะครับ

เเล้วที่ไม่สามารถดึงมาโดยตรงด้วย simplexml_load_file("test.xml") ได้เนื่องจาก มันถูกเขียนเป็น .php แล้ว echo ออกมาเป็น xml อะครับผมก็เลยเอามาใช้ต่อทันทีไม่ได้

อย่างไรกวนด้วยน่ะครับ ขอบคุณครับ

Re: สอบถามการใช้ file_get_contents ครับ

โดย mindphp » 27/10/2009 1:55 pm

มันเปิดไฟล์เป้าหมายที่ต้องการอ่านไม่ได้ครับ ไฟล์ที่ต้องการอ่านอยู่ที่ไหน?

สอบถามการใช้ file_get_contents ครับ

โดย darksoullest » 27/10/2009 1:40 pm

ไม่ทราบว่า fuction ตัวนี้มันต้องเปิดอะไรใน php.ini ก่อนรึเปล่า เพราะมัน error ออกมาครับ

รบกวนผู้รู้ทุกท่านช่วยด้วยครับ

โดยโค้ดเป็นประมาณนี้ ครับ

code :

$xml = file_get_contents("http://test.php");
echo $xml;

response :


Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\Inetpub\wwwroot\code\test.php on line 3

Warning: file_get_contents(http://test.php) [function.file-get-contents]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\code\test.php on line 3

ข้างบน