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

来源:互联网 发布:淘宝女装哪个货源好 编辑:程序博客网 时间:2024/06/05 11:51

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)));
        $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);

原创粉丝点击