2016-11-19 89 views
2

我有一个脚本代码会重定向到访问多个GET参数

http://localhost:8080/generated/sample/ + $('form.wpcf7-form').serialize(); 

和样品产生的那个URL的

http://localhost:8080/generated/sample/_wpcf7=222&_wpcf7_version=4.5.1&_wpcf7_locale=en_US&_wpcf7_unit_tag=wpcf7-f222-p37-o1&_wpnonce=35162dc550&your-name=Robert+Soriano&your-email=sorianorobertc%40gmail.com&mobile-number=39174535417 

序列化值从Contact Form 7插件的WordPress。

在我纤细的路线我有

<?php 
// Routes 

$app->get('/{name}', function ($request, $response, $args) { 
    // Sample log message 
    $this->logger->info("Slim-Skeleton '/' route"); 

    // Render index view 
    return $this->renderer->render($response, 'index.phtml', $args); 
}); 

$app->get('/generated/sample/', function ($request, $response, $args) { 
    return $args['your-email']; 
    // How to access different parameters here? 
}); 

而我得到的是这种

enter image description here

这就像第一路由工作这一点,但不是我想要的路线。

如何在我的路线中访问像名称,电子邮件和所有这些参数?

任何帮助将不胜感激。

回答

3

您可以使用$request->getQueryParams()访问查询字符串参数。 IE浏览器。像

$params = $request->getQueryParams(); 
$email = $params["your-email"]; 

或更短的版本。

$email = $request->getQueryParam("your-email");