Why this:
echo $this->Html->link('Add a User', array('controller'=>'users', 'action'=>'add'));
Instead of just this:
echo $this->Html->link('Add a User', 'users/add');
The second example will always generate a url of 'users/add'. The first provides the potential of using reverse routing to form a bespoke url, as defined by the rules in your routes.php file.
In practice I often find that there's no difference between the first and the second style. However, if you later decide to make changes to your routes, you might find that doing things the first time saves time in the long run, so you don't have to go back and change the path for every link...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With