file_get_contents和\n的那些事

By Symphony - Last updated: Tuesday, December 22, 2009 - Save & Share - 2 Comments

用file_get_contents去获取一段url的内容,结果总是显示404,实际上页面是存在的。搞了半天不明白,后来发现报错的url后带一个空白,猜想可能是url后面多了\n的话file_get_contents就会报错,就在url上加了个trim,马上就成功了!!-_-这file_get_contents的容错性真是……

Posted in Uncategorized • Tags: Top Of Page

2 Responses to “file_get_contents和\n的那些事”

Comment from 天缘
Time 2010/01/30 at 10:07 pm

还是严格一点好啊,容错性太高对程序员不好:)

Comment from willin
Time 2010/03/15 at 2:35 pm

我也碰到了一样的问题,不管用file_get_contents还是sock都是得到404面页
网址是:http://www.21food.cn/news/more_market.jsp?pageNo=2&category=25
兄弟要是有时间帮着看看哈!
忘 了说:trim试过了

Write a comment