Analysis of _php instances of abandoned Getrequest () method in Symfony2

Source: Internet
Author: User
Tags deprecated php database

The abandoned Getrequest () method in Symfony2 is analyzed in this paper. Share to everyone for your reference, specific as follows:

When Symfony was recently used, the Getrequest () method found in NetBeans was abandoned:

/**
 * Shortcut to return the request service.
 *
 @return Request
 * *
 @deprecated deprecated since version 2.4, to is removed in 3.0.  Ask
 *       Symfony to inject the Request object into your controller
 * method       instead by type hinting it in the Method ' s signature.
 */Public
function Getrequest ()
{return
  $this->container->get (' Request_stack ')-> Getcurrentrequest ();
}

Google a bit, and found that should be so written:

Use Symfony\component\httpfoundation\request;
Public Function updateaction (Request $request)
{
  $foo = $request->get (' foo ');
  $bar = $request->get (' Bar ');
}

Post method please use:

$foo = $request->request->get (' foo ');

Get method Please use:

$foo = $request->query->get (' foo ');

For more information on PHP-related content readers can view the site topics: "PHP operation Office Document tips summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP object-oriented Program Design Introductory Course", "PHP string (string) Summary of usage, Getting Started tutorial on Php+mysql database operations, and summary of common PHP database operations techniques

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.