php-get和post请求

1.get请求

<?php

//判断20130101是否是工作日
//工作日对应结果为 0, 休息日对应结果为 1, 节假日对应的结果为 2;
$url='http://www.easybots.cn/api/holiday.php?d=20130101';

$output= file_get_contents($url);

?>

2.post请求

<?php
$url = "http://xxxxx";
$post_data = array ("key1" => "value","key2"="value");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// post数据
curl_setopt($ch, CURLOPT_POST, 1);
// post的变量
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
#print_r($output);
?>