Parse error: syntax error, unexpected $end in /app/views/layouts/default.ctp – CakePHP

I just encountered an unexpected error while creating a portable development server on a USB stick using the latest version of XAMPP portable. This particular application runs on the CakePHP framework and was copied directly from another functioning Windows based machine.

After scratching my head a few moments I realized that the default configuration for XAMPP’s php.ini may be different.

The fix is easy. Go into your php.ini for your php installation and change the following from ‘OFF’ to ‘On’:

short_open_tag = on

Then simply go and restart your apache to apply the changes.

How To: CakePHP form input without labels

One of the great things about CakePHP is how easy it is to get very common tasks accomplished in a short amount of time. Form building is no exception, but there are many options to specify – and at times those options are not immediately apparent.

The standard input code syntax appears like this:

input(string $fieldName, array $options = array())

To have your form inputs not show labels, you can specify ‘label’=>false in the input options.

For example:

echo $form->create(‘User’, array(‘action’ => ‘login’, ‘class’=>’header-login’));
echo $form->input(‘username’, array(‘label’ => false));
echo $form->input(‘password’, array(‘label’ => false));
echo $form->end(‘Login’);

This will show your form inputs without the label elements.