The update function itself calls a class to send an email. This would fail when asked to loop with "cannot redeclare class", so I used this (which used to work):-
Code: Select all
$classes = get_declared_classes();
if(!in_array('email',$classes)) {
include('classes/class_email.php');
$em = new email; }
}
$em->send_email($to, $subject, $message);Here are three test scripts that show this...
THE SCRIPT IN A FILE CALLED test.php
Code: Select all
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include('test_class1.php');
$test_class1 = new test_class1;
echo 'Script start<br />';
for($i=0; $i<3; $i++) {
$test_class1->show_test1_output($i);
}
echo 'Script finish<br />';
?>Code: Select all
<?php class test_class1 {
var $test_string1 = 'class_test1 output';
function show_test1_output($loop) {
echo $this->test_string1.' loop '.$loop.'<br />';
$classes = get_declared_classes();
if(!in_array('test_class2',$classes)) {
include('test_class2.php');
$test_class2 = new test_class2;
}
echo $test_class2->show_test2_output();
}
}
?>Code: Select all
<?php class test_class2 {
var $test_string2 = 'class_test2 output';
function show_test2_output() {
echo $this->test_string2.'<br />';
}
}
?>Script start
class_test1 output loop 0
class_test2 output
class_test1 output loop 1
Notice: Undefined variable: test_class2 in /home/ourclien/public_html/test_class1.php on line 12
Fatal error: Call to a member function show_test2_output() on a non-object in /home/ourclien/public_html/test_class1.php on line 12
and if you comment out the "if(!in_array('test_class2',$classes)) {" in test_class1.php you get this...
Script start
class_test1 output loop 0
class_test2 output
class_test1 output loop 1
Fatal error: Cannot redeclare class test_class2 in /home/ourclien/public_html/test_class2.php on line 1
I fear it might be a PHP setup issue but I don't know what to ask of my host.