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);
在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);
相关文章推荐
- 设置局域网PHP环境IP访问
- 设置局域网PHP环境IP访问
- PHP入门之局域网多站点访问、带参数请求、Json数据、Xml数据
- 本地搭建了PHP+Apache环境,何让局域网内的人都能访问我的电脑上的本地网站
- (IIS)网站本地放置,域名虚拟,权限设置,局域网访问网站图片无法显示之解决办法
- PHP与MySql数据库访问编码类型设置
- php将字符串随机分割成不同长度数组的方法
- 局域网内访问机器时出现“未授予在次计算机上的请求登陆类型”
- beego开发web服务+fiddler模拟Post请求+以json类型发送数据
- php实现扫描二维码根据浏览器类型访问不同下载地址
- php将字符串随机分割成不同长度数组的方法
- (php的弱类型导致的小问题)某变量可能是数字或非数字(对象、字符串、json等)时,应该如何去判断
- 花生壳路由器设置(通过外网访问本地局域网)
- windows快速搭建本地apache php mysql开发环境,多站点域名访问
- Apache 设置本地(局域网)访问
- 根据URL判断是否本地局域网访问(PHP代码函数)
- php面向对象不同类型成员访问方法 小结
- IIS设置可以让本地局域网访问
- 路由器设置,实现不同局域网下主机的相互访问
- windows快速搭建本地apache+php+mysql开发环境,多站点域名访问