得到的东西似乎不起作用.说我有一个网址
www.test1.php?WC.id = 12345
然后以下返回任何内容
$_GET['WC.id'];
Run Code Online (Sandbox Code Playgroud)
如果我删除WC.部分,然后它返回12345.我可以在我的网址参数名称中没有句号吗?
谢谢
我有一个如下所示的数组
array:7 [?
0 => array:7 [?
"id" => "62"
"name" => "creativeOption"
"label" => "Other"
"value" => "dfsdfsdfsdf"
"someId" => "14"
]
1 => array:7 [?
"id" => "60"
"name" => "creativeOption"
"label" => "checkboxSelection"
"value" => "AnimSomething"
"someId" => "14"
]
2 => array:7 [?
"id" => "61"
"name" => "creativeOption"
"label" => "checkboxSelection"
"value" => "Something"
"someId" => "14"
]
3 => array:7 [?
"id" => "59"
"name" => "creativeNumber"
"label" => "Something"
"value" => ""
"someId" …Run Code Online (Sandbox Code Playgroud) 我有一个名为 Campaign 的模型,它采用以下结构
+----+--------------+-----------------+----------+---------------+--------------+--------------------+----------+-------+--------+---------------------+---------------------+
| id | campaignName | userId | clientId | clientContact | contactEmail | campaignObjectives | acNumber | notes | active | created_at | updated_at |
+----+--------------+-----------------+----------+---------------+--------------+--------------------+----------+-------+--------+---------------------+---------------------+
| 1 | test | 7 | 10 | Mr Fakes | 12345 | sdfsdfsd | 12345 | | 0 | 2016-02-29 11:51:59 | 2016-02-29 13:51:28 |
+----+--------------+-----------------+----------+---------------+--------------+--------------------+----------+-------+--------+---------------------+---------------------+
Run Code Online (Sandbox Code Playgroud)
然后我有一个具有以下结构的 CampaignTypes 模型
+----+--------------+-----------------+------------+---------------------+---------------------+
| id | campaignType | creativeArrival | campaignId | created_at | updated_at |
+----+--------------+-----------------+------------+---------------------+---------------------+
| 14 | Dynamic …Run Code Online (Sandbox Code Playgroud) 我进行API调用并返回一些JSON.然后我使用解析这个JSON
var json = $.parseJSON(result);
Run Code Online (Sandbox Code Playgroud)
为了达到我在这个json对象中所需的级别,我做了类似的事情
console.log(json.data[0].value)
Run Code Online (Sandbox Code Playgroud)
这将在控制台上打印如下内容
Option "1166325"
Option Two "3329076"
Run Code Online (Sandbox Code Playgroud)
所以,如果我这样做
console.log(json.data[0].value.Option)
Run Code Online (Sandbox Code Playgroud)
我打印出1166325.但是如果我这样做的话
console.log(json.data[0].value.Option Two)
Run Code Online (Sandbox Code Playgroud)
我在参数列表后得到一个错误SyntaxError:missing).我也试过了
console.log(json.data[0].value.['Option Two'])
Run Code Online (Sandbox Code Playgroud)
但这会返回SyntaxError:之后缺少名称.操作者
考虑到名称中有空格,我该如何访问这些数据呢?
谢谢
我传递了一个包含一些答案的对象.然后我执行以下操作来创建关联数组
$field_data = array();
foreach($submission->answers as $answer) {
$field_data[$answer->question_id] = $answer->text + 1;
}
Run Code Online (Sandbox Code Playgroud)
这导致像这样的数组
array:15 [?
1 => 3
2 => 4
3 => 2
4 => 5
]
Run Code Online (Sandbox Code Playgroud)
我需要做的是使用上面的数据构建一个API调用.API URL看起来像这样
someAPI.com?api.php?function=calculatePrice&question 1 = 3&question2 = 4&question3 = 2&question4 = 5
问题编号是数组左侧的值,而=符号后面的部分是数组右侧的值.
使用我拥有的数组创建此URL的最佳方法是什么?
谢谢
我只是想知道一些事情.在index.php中,我目前正在做这样的事情
function performFtpOperation() {
global $config;
try {
$ftp = new FTP\FtpClient();
$ftp->connect($config::FTP_SERVER);
$ftp->login($config::FTP_USER, $config::FTP_PASSWORD);
} catch (Exception $e) {
echo 'Error: ', $e->getMessage();
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道的是,是否需要尝试catch块?我怀疑的原因是因为如果出现问题我的FTP类会抛出错误.例如,这是连接功能
public function connect($host, $ssl = false, $port = 21, $timeout = 90)
{
if ($ssl) {
$this->conn = @$this->ftp->ssl_connect($host, $port, $timeout);
} else {
$this->conn = @$this->ftp->connect($host, $port, $timeout);
}
if (!$this->conn) {
throw new Exception('Unable to connect');
}
return $this;
}
Run Code Online (Sandbox Code Playgroud)
如果在类中处理错误,是否需要try/catch?
谢谢