Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7641285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:53:02+00:00 2026-05-31T08:53:02+00:00

I was reading the CakePHP manual on $params and was wondering what the appropriate

  • 0

I was reading the CakePHP manual on $params and was wondering what the appropriate usage is for each? I know that the array that is returned is slightly different (‘url’ actually has an array key called ‘url’ that returns the controller/action, and that ‘named’ does not. Can someone show an example of why it would be important to use one over the other? (I saw the structure difference in the url as well and didn’t know why the difference between key:value and key=value)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:53:03+00:00Added an answer on May 31, 2026 at 8:53 am

    TLDR: For CakePHP 2.x: Whether to use params[‘named’] or params[‘url’] just depends on what data you’re looking for. ‘url’ returns a string of the entire url after the domain, and ‘named’ returns an array of any passed “named” variables (comma-separated key:value pairs)


    CakePHP 3.x: no ‘named’ variables


    Explained in more depth:

    The best way to get an idea of why you’d use one of the other is debug params in a view:

    debug($this->params);

    You’ll see, there is a LOT of data in the params array. For example, with my url: http://www.example.com/dashboards/index/1/2/blah:test

    params => array(
        'plugin' => null,
        'controller' => 'dashboards',
        'action' => 'index',
        'named' => array(
            'blah' => 'test'
        ),
        'pass' => array(
            (int) 0 => '1',
            (int) 1 => '2'
        ),
        'models' => array(
            'Dashboard' => array(
                'plugin' => null,
                'className' => 'Dashboard'
            ),
            //...
        )
    )
    data => array()
    query => array(
        'dashboards/index/1/2/blah:test' => ''
    )
    url => 'dashboards/index/1/2/blah:test'
    base => ''
    webroot => '/'
    here => '/dashboards/index/1/2/blah:test'
    

    As you can see, it has a LOT of data. Your question of “why would you use “named” vs “url” is explained just by looking at the data.

    $this->params['url'] returns the STRING 'dashboards/index/1/2/blah:test' (not very usable in most cases).

    $this->params['named'] returns a key/value ARRAY of your named variables (in this case, just one variable): array('blah' => 'test'); (much more usable if that’s what we’re looking for)

    So… the answer is, if you want the named variables, use 'named' – if you want the end of the URL as a string, use 'url‘.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting to use CakePHP, and I'm in the process of reading the manual
I've been reading CakePHP's 2.0 migration guide where it's stated that cakeError() has been
Reading through the following instruction table manual I see that integer multiplication is often
I am currently reading Beginning CakePHP:From Novice to Professional by David Golding. At one
I'm struggling to implement ACL in CakePHP. After reading the documentation in the cake
Reading through this question on multi-threaded javascript, I was wondering if there would be
Reading through the CKEditor documentation , I see that they have an option to
Reading Chomsky hierarchy ... ... I know regexp can't parse type-2 grammars (context-free grammars),
after reading 'What is the best way to create global variables in CakePHP?' in
I'm new to CakePHP and I'm stuck in reading a Model using other fields.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.