您的位置:首页 > 编程语言 > PHP开发

php 本地环境 局域网 访问设置 json 模拟请求 字符串不同类型分割

2017-05-17 14:41 447 查看
cdm     

在dos下输入 ipconfig 找到对应的的ip

在host 添加    

127.0.0.1     192.168.1.88 

局域网就可以访问自本地     网站了

json 模拟请求

 function api_post($url, $jsonStr)

    {

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_POST, 1);

        curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($jsonStr)));<
4000
br />
        $response = curl_exec($ch);

        return $response;

    }

字符串分割

$arr = preg_split("/([a-zA-Z0-9]+)/", $str, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);  

print_r($arr);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: