English 中文(简体)
如何在 Symfony2 中获取所有员额参数? [重复]
原标题:How to get all post parameters in Symfony2? [duplicate]
  • 时间:2012-05-24 13:39:38
  •  标签:
  • php
  • symfony

我想得到""http://symfony.com/" rel="noreferrer">symfony Form。

我用过:

$all_parameter = $this->get( request )->getParameterHolder()->getAll();

我得到这个错误

Fatal error: Call to undefined method SymfonyComponentHttpFoundationRequest::getParameterHolder() in /Library/WebServer/Documents/Symfony/src/Uae/PortailBundle/Controller/NoteController.php on line 95
最佳回答
$this->get( request )->request->all()
问题回答

Symfony < a href=" "http://api.symfony.com/2.0/Symfony/Component/HtpFoundation/Resources.html" "请求对象 具有代表请求不同部分的相当几种公共属性。 描述它的最简单方式可能是向您展示 请求的代码: 初始化()

/**
 * Sets the parameters for this request.
 *
 * This method also re-initializes all properties.
 *
 * @param array  $query      The GET parameters
 * @param array  $request    The POST parameters
 * @param array  $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
 * @param array  $cookies    The COOKIE parameters
 * @param array  $files      The FILES parameters
 * @param array  $server     The SERVER parameters
 * @param string $content    The raw body data
 *
 * @api
 */
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
{
    $this->request = new ParameterBag($request);
    $this->query = new ParameterBag($query);
    $this->attributes = new ParameterBag($attributes);
    $this->cookies = new ParameterBag($cookies);
    $this->files = new FileBag($files);
    $this->server = new ServerBag($server);
    $this->headers = new HeaderBag($this->server->getHeaders());

    $this->content = $content;
    $this->languages = null;
    $this->charsets = null;
    $this->acceptableContentTypes = null;
    $this->pathInfo = null;
    $this->requestUri = null;
    $this->baseUrl = null;
    $this->basePath = null;
    $this->method = null;
    $this->format = null;
}

因此,如你所见, request:$request 是POST参数的ParameterBag





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签