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

  • Home
  • SEARCH
  • 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 6603005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:56:57+00:00 2026-05-25T18:56:57+00:00

CakePHP HtmlHelper link() method accepts 2 types of variable as second parameter (the link

  • 0

CakePHP HtmlHelper link() method accepts 2 types of variable as second parameter (the link URL param).

Now I wonder if using array for the param, like

array('controller'=>'users','action'=>'login')

is slower than using string, like '/users/login'. Because Helper won’t have to parse the array, just display the link.

If it is so, then what is the purpose of link() method? For now, I am using HtmlHelper::url() method with a regular <a> to display all of my links, to keep my template clean!

Please correct me 🙂

  • 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-25T18:56:57+00:00Added an answer on May 25, 2026 at 6:56 pm

    One reason is reverse routing: For examples, if you route ‘/blah’ to array(‘controller’=>’articles’,’action’=>’index’). When you create the link with array(‘controller’=>’articles’,’action’=>’index’), cake can automatically output ‘/blah’. It may not sound very interesting; but if later on you change the route to ‘/foo’, then the link() method can automatically change the output to ‘/foo’.

    Another reason is: using array you can build the url in a programmatic fashion. It’s not just controller and action, you also have prefix, named parameters, your own custom parameters if you create in routes, etc.

    For now, I am using HtmlHelper::url() method with a regular <a> to display all of my links, to keep my template clean! Well, you are making it harder on yourself then 🙂

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

Sidebar

Related Questions

I'm generating plain simple links with CakePHP's HtmlHelper the following way: $html->link(Newest, array( 'controller'
I'm using the cakephp url HTML helper like following: <?php echo $this->Html->url(array('controller' => 'communities',
Using CakePHP 1.3 there are named parameters in the URL like .../name:value/... These are
Using cakephp, I have a generic address table, which I want to link to
In a CakePHP 1.2 app, I'm using <?php $session->flash();?> to output messages like Record
I am using cakephp framework to build my application. I want that, whenever a
I am using CakePHP framework with MySQL database and I have problem in saving
I have a cakephp installation in the root of my domain. Now it turns
In Cakephp is there a better way to write this: $unread_orders = $this->Order->find('all', array('conditions'
Using CakePHP 1.3 , I post a form which correctly fills in $this->data .

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.