Archive for December, 2011

If you get this error:
1Warning: Warning (2): preg_match() [<a href=’function.preg-match’>function.preg-match</a>]: Delimiter must not be alphanumeric or backslash in [/var/www/vhosts/h2oservices.com/httpdocs/cake/libs/model/model.php, line 2611]
When trying to use a custom validation rule, make sure the method visibility is set to public.
So this should work:
123public function myCustomValidateRule(){
    // Custom validation code
}
It seems protected visibility works on some versions of [...]

Ternary in PHP Heredoc

15, Dec 2011

It can’t be done using the normal Ternary operator but you can emulate it with:
12345678910111213// So instead of:

$str = <<<HTML
{$a ? 1 : 2}
HTML;

// You can do:

$values = array(’1′, ‘2′);

$str = <<<HTML
{$values[$a]}
HTML;


top