码迷,mamicode.com
首页 > 其他好文 > 详细

file_get_contents高級用法

时间:2014-09-24 10:57:36      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:http   io   os   ar   sp   cti   on   c   amp   

Set_time_out(0);//防止脚本超时

function Post($url, $post = null){
        $context = array();
        if (is_array($post)) {
            ksort($post);

            $context[‘http‘] = array (
                ‘timeout‘=>60,
                ‘method‘ => ‘POST‘,
                ‘content‘ => http_build_query($post, ‘‘, ‘&‘),
             );
        }

        return file_get_contents($url, false, stream_context_create($context));
    }

    $data = array (
        ‘name‘ => ‘test‘,
        ‘email‘ => ‘test@gmail.com‘,
        ‘submit‘ => ‘submit‘,
     );

     echo Post(‘http://www.example.com‘, $data);

file_get_contents高級用法

标签:http   io   os   ar   sp   cti   on   c   amp   

原文地址:http://www.cnblogs.com/xiashuo-he/p/3989880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!