I would like to expand and mention a few things.
Inline script
The built-in script tag opens, which is not always needed.
<?php echo $this->Html->script('script.name'); ?>
Non-inline script
This will host the script where you placed $ this-> fetch ('script') in your layout file, usually at the top of the page. (As ub3rst4r pointed out, you passed false as a string)
<?php echo $this->Html->script('script.name', array('inline' => false)); ?>
Script block
This can be a much more useful version for many people, you can put a script block in any layout file (as much as you want). I will show you an example and call it scriptBottom to go to the end of my body.
<?php echo $this->fetch('scriptBottom'); ?>
You can then pass the block to a script method like
<?php $this->Html->script('script.name', array('block' => 'scriptBottom')); ?>
Hope this helps
source share