Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7704759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:45:11+00:00 2026-05-31T23:45:11+00:00

I’m quite new to PHP so I don’t know how to solve this error.

  • 0

I’m quite new to PHP so I don’t know how to solve this error. I’ve been reading the related posts here, but as I said I’m too little experienced to know hot to apply similar solutions 🙁

Here’s the thing:
In my main php file I have:

require_once("SentDocument.php"); 
$sent = new SentDocument();
$sent->myfunction(param1, param2);

And in SentDocument.php

class SentDocument {
        public function myfunction (&$param1, &$param2, &$sError)
        { // inside goes an sql query using param1 and param2 
        }   
}

With this I’m getting:
Call to undefined function myfunction() in … pointing to this line in my main php file:

$sent->myfunction(param1, param2);

The odd thing is: when writting in my main php file:

$sent-> 

the php editor I’m using shows in a context window myfunction() so I can pick it up .. this means SentDocument.php is well linked and the function is available, right?

So why do I get the error? What am I doing wrong?

Thanks a million!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:45:13+00:00Added an answer on May 31, 2026 at 11:45 pm

    The function myfunction should be in a class to be able to call using an instance. So:

    class SendDocument
    {
        public function myfunction (&$param1, &$param2, &$sError)
        { // inside goes an sql query using param1 and param2 
        }   
    }
    

    BTW why are you adding those parameters by reference &. Do you need to change them inside the function.

    Also: $sent->myfunction(param1, param2); will result in a syntax error. If param1 and param2 are strings you should encapsulate them in quotes (either double or single) of or they are variables they should have a dollarsign ($) in front of it. My guess is that they should be variable since yu are trying to pass them by reference to the function (The ampersand sign & in the function declaration).

    Another thing you have three required parameters in that function, but you are trying to call the function with only two parameters. So you shoudl either provide the third parameter when calling the function or you should make the third parameter option (by giving it a default value).

    In you case I would change the structure to something like the following (semi pseudocode):

    class SendDocument
    {
        protected $errors = array();
    
        public function myfunction ($param1, $param2)
        {
            // run query
    
            // if something went wrong
            if (!$recordset) {
                $this->addError($theError, $query);
            }
    
            return $recordset;
        }
    
        protected function addError($error, $query) {
            $this->errors[] = array($error, $query);
        }
    
        public function getLastError() {
            if (empty($this->errors)) return null;
    
            return $this->errors[0];
        }
    
    }
    
    require_once("SentDocument.php"); 
    $sent = new SentDocument();
    $recordset = $sent->myfunction('param1', 'param2');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.