Page 1 of 1

Functions in UDTs

Posted: Wed Mar 27, 2013 10:15 am
by psy
I knew this before but forgot and wasted a lot of time wondering why my UDT kept crashing on the 2nd iteration.

Functions declared in UDT's are remembered. Wrap them in the PHP function:

Code: Select all

if (!function_exists ('myfunction') {
  function myfunction (){
  ...
  }
}
That way when it's called again, eg in a {foreach} loop, all will go well.

hth
psy