Change php code with function -


i have problem piece of code. code works fine. no problem.

include ("ccheckmail.php");  $checkmail = new ccheckmail (); $emails = array ("korkula@iservicesmail.com");  foreach ($emails $email)  {      if ($checkmail->execute ($email)) { return 1; } else { return 0; }  }// end foreach 

and now, want change instead use array, want send email check var, this:

include ("ccheckmail.php"); funtion_name($email){     $checkmail = new ccheckmail ();     if ($checkmail->execute ($email)) { return 1; } else { return 0; }  }   } //end function 

the new code doesnt work dont understand why.

can me?

thanks!

try declaring object once , reusing passing function email address you're checking.

//call checkmail class include("ccheckmail.php");  //define object work $checkmail = new ccheckmail();  //function send emails , return response function checkemailfunc($email, $emailobject){         if ($emailobject->execute ($email)) { return 1; } else { return 0; }  }  //test out $emails = array("korkula@iservicesmail.com", "test@example.com"); foreach ($emails $email) {      if (checkemailfunc($email, $checkmail)) {         echo "success! checked " . $email . "<br/>";     } else {         echo "failed check " . $email . "<br/>";     } } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -