PHP获取url的函数代码

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

function geturl($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//在需要用户检测的网页里需要增加下面两行
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.”:”.US_PWD);
$contents = curl_exec($ch);
curl_close($ch);
$contents = str_replace("document.write('","",$contents);
$contents = str_replace("');","",$contents);
$contents = str_replace("\\n","",$contents);
$contents = str_replace("\\","",$contents);
echo $contents;
}

相关文章

PHP简单创建日历的方法

PHP简单创建日历的方法

本文实例讲述了PHP简单创建日历的方法。分享给大家供大家参考,具体如下: <?php function build_calendar($month,$year) {...

PHP简单读取xml文件的方法示例

本文实例讲述了PHP简单读取xml文件的方法。分享给大家供大家参考,具体如下: 我将软件版本更新中的版本号等数据信息存放在xml文件中,使用时将版本信息读取出来。 xml文件内容如下:...

GBK的页面输出JSON格式的php函数

复制代码 代码如下:function tb_json_encode($value, $options = 0) { return json_encode(tb_json_convert_...

PHP中使用OpenSSL生成证书及加密解密

依赖于OpenSSL扩展 /*加密解密*/ function authcode($string, $operation = 'E') { $ssl_public = file_g...

php多用户读写文件冲突的解决办法

一般的方案会是:复制代码 代码如下:$fp = fopen("/tmp/lock.txt", "w+");if (flock($fp, LOCK_EX)) {  &n...