在PHP中我需要获取URL(源)的内容搜索字符串"也许宝贝爱你",如果它不包含这个,那么做x.
只需阅读页面内容就像读取文件一样.PHP为您完成连接.然后只需通过正则表达式或简单的字符串比较查找字符串.
$url = 'http://my.url.com/'; $data = file_get_contents( $url ); if ( strpos( 'maybe baby love you', $data ) === false ) { // do something }
//The Answer No 3 Is good But a small Mistake in the function strpos() I have correction the code bellow. $url = 'http://my.url.com/'; $data = file_get_contents( $url ); if ( strpos($data,'maybe baby love you' ) === false ) { // do something }