Error while running Function on another file

Asked

Viewed 33 times

-3

Inside the insert.php file I have a function that validates sending to the database and then sends a return email, the problem that when checking the send.php file that will execute the code of the following error.

Fatal error: Call to Undefined method email::envioemail() in

Follows:

insert.php

include("envia.php");
$envia=new email();
$envia->envioemail();

php sending.

class email {
function enviaemail() {
  • 2

    envioemail for enviaemail, is a the by a to.

  • 1

    The name of the include file is also wrong. Tip: Class name starts with uppercase letter, and better always declare the scope of a method.

  • 1

    Kkkkkkk do not believe. The file is right. I write wrong there. After lunch I test.

  • 1

    is calling "envioemail()" and the method name is "enviaemail()".. notice the error? changed the letter "a" by the letter "o".

  • Yes. kkk was the problem.

1 answer

2


There are some errors in the code. It should look something like this:
File structure

SeuProjeto  
|--inserir.php 
|--class //folder
|-------Envio.php

With that your code would look like this:
insert.php

include("class/Envio.php");
$envia = new email();
$envia->envioemail();

Sending.php

class email 
{
   function envioemail() 
   {
     //SUA FUNÇÃO AQUI
   }
}

I hope I’ve helped.

  • Then I set the function enviaemail(), and in the other file the function was sent mail(). That was the only error. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.