0
我在Drupal 8网站上工作。在一个页面中,我有一个包含GET方法的表单的PHP块。PHP恢复完整的URL drupal 8
在接收信息的页面中,我有一个看起来像site/page?param1=value1¶m2=value2
的网址。我需要得到value2。
我试过很多解决方案,但我没有找到解决办法:
$_GET['id'];
// returns : null
\Drupal::service('path.current')->getPath();
// returns : '/node/4'
$_SERVER['PHP_SELF'];
// returns : 'site/page'
$_SERVER['REQUEST_URI'];
// returns : 'site/page'
$_SERVER['argv'];
// returns : null
$_SERVER['HTTP_REFERER'];
// returns : 'http://site/node/4/edit'
\Drupal::request()->query->all();
// returns : array (size=0) empty
$path = \Drupal::request()->getpathInfo();
// returns : '/page'
\Drupal::request()->getRequestUri();
// returns : 'site/page'
\Drupal::request()->attributes->get('_system_path');
// returns : null
\Drupal::service('path.alias_manager')->getAliasByPath($current_path);
// returns : '/page'
$_SERVER['QUERY_STRING'];
// returns : ''
\Drupal::destination()->getAsArray();
// returns : 'site/page'
有人可以帮我找到这个值2这是在网址是什么?
当我尝试这个时,我得到了一个“null”。我认为问题出在这个形式上,我会试着去看这个。谢谢。 – Elehyan
什么是真正的URL?你能否在这里添加你的表单代码?并为您的表单提供动力的路由文件(routing.yml)。 –
你也可以尝试使用'CurrentRequest'而不是'MasterRequest'。例如。 '$ request = $ requestStack-> getCurrentRequest();'如果有效,你在一个SubRequest中,检查我给你的关于请求的链接。 –