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

  • Home
  • SEARCH
  • 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 6756529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:32:07+00:00 2026-05-26T13:32:07+00:00

If I have a class, abstract class Parent { abstract function foo(); } class

  • 0

If I have a class,

abstract class Parent {
    abstract function foo();
}

class Child extends Parent {
    function foo($param) {
        //stuff
    }
}

I get an error because the abstract declaration doesn’t have any parameters but the child’s implementation of it does. I am making an adapter parent class with abstract functions that, when implemented, could have a variable amount of parameters depending on the context of the child class. Is there any structured way I can overcome this, or do I have to use func_get_args?

  • 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-26T13:32:07+00:00Added an answer on May 26, 2026 at 1:32 pm

    You have to use func_get_args if you want to have variable arguments in your function. Note that func_get_args gets all the arguments passed to a PHP function.

    You can however enforce a minimum number of arguments to be passed to the function by including corresponding parameters to them.

    For example:
    Say that you have a function that you wish to call with at least 1 argument. Then just write the following:

    function foo($param) {
        //stuff
        $arg_list = func_get_args();
    }
    

    Now that you have this definition of foo(), you have to at least call it with one argument. You can also choose to pass a variable number of arguments n where n > 1, and receive those arguments through func_get_args(). Keep in mind that $arg_list above will also contain a copy of $param as its first element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent class: Abstract Class Base { function __construct($registry) { // stuff
If I have a parent-child that defines some method .foo() like this: class Parent
Let's say I have something like this: abstract class Parent { protected function foobar($data)
I have an abstract class defined as follows: abstract class Abstract Parent extends Zend_Db_Table_Abstract
I have parent and child classes as follows: abstract class ParentObj { private $data;
I have like: class Class2 extends Class1 { ..... function __construct() { parent::__construct(); $var_in_included_file;
I have the following structure: abstract class Parent {} class Child : Parent {
I have the following code: abstract class BaseLpmServiceForm extends BaseFormPropel { public function setup()
I have a abstract Parent class that has multiple children. I'd like the child
I have an abstract base class class AbstractClass { Col<AbstractClass> parent public AbstractClass() {

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.