【发布时间】:2015-11-25 20:01:41
【问题描述】:
我正在与 Curl 合作向 php 脚本提出一些请愿书,我正在尝试如下所示提出请愿书,我的脚本是 ajax2.php
$params=['name'=>'John', 'surname'=>'Doe', 'age'=>36,'method'=>'prueba'];
$defaults = array(
CURLOPT_URL => getcwd().'\src\myApp\ajax2.php',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($params),
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
curl_exec($ch);
if (curl_errno($ch)) {
// this would be your first hint that something went wrong
die('Couldn\'t send request: ' . curl_error($ch));
}
但我收到此错误:Couldn't send request: Could not resolve host: C 那么,我应该如何调用项目文件夹中的脚本?
【问题讨论】:
-
您应该使用带有 http 或 https 的 URL。如果您在本地主机中,则
CURLOPT_URL => 'http://localhost/YOUT_APP_DIR/src/myApp/ajax2.php', -
@jibon57 谢谢老兄!成功了!