If you're writing some custom PHP to embed into layouts, you'll find it difficult to write a function of your own.
PHP doesn't allow a function to be redeclared. Most Layouts are repeated as successive pages are built causing an attempted redeclaration and a warning message is issued.
The way around this is to declare your function conditionally upon it's own non-existence. E.g.
PHP doesn't allow a function to be redeclared. Most Layouts are repeated as successive pages are built causing an attempted redeclaration and a warning message is issued.
The way around this is to declare your function conditionally upon it's own non-existence. E.g.
Code:
<actinic:block php="true"> if ( ! function_exists('mypythagoras') ){ function mypythagoras($x, $y){ $z = sqrt($x*$x + $y*$y); return $z; } } echo '<br>3, 4 has hypotenuse: ' . mypythagoras(3, 4); echo '<br>2, 2 has hypotenuse: ' . mypythagoras(2, 2); </actinic:block>
Comment