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 493925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:27:02+00:00 2026-05-13T05:27:02+00:00

I have an abstract class defined as follows: abstract class Abstract Parent extends Zend_Db_Table_Abstract

  • 0

I have an abstract class defined as follows:

abstract class Abstract Parent extends Zend_Db_Table_Abstract { 
    abstract function funcA($post);
    abstract function funcB();

    public function newEntry($post) {  
        $t1 = $this->funcA($post);
        $t2 = $this->funcB();
    }
}

The child class defines the two abstract methods, as follows:

require_once 'atablemodel.php';

class Child extends AbstractParent {    
    public function funcB() 
    {
        return 'Some Value';
    }

    public function funcA($post) 
    {
        $data = array(
            'v1'    => htmlentities($post['v1'])
        );
        return $data;
    }
}

However, when I try this, I get an error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/.../abstractparent.php on line 27

which is the line where the abstract parent is calling one of the abstract methods. What I want to have happen is that this line should call the child method, which is defined.

Now, I assume that there is a way to do this, and since I’m a beginner to PHP, I’m doing something fundamentally wrong. Any suggestions as to what I might do to resolve this? If I were to define the two abstract methods as having implementations, and then overriding those methods in all children (that is, not deal with abstract classes at all), how would I ensure that the parent calling one of those methods would call the appropriate child method at execution time?

EDIT

In light of the various comments about the issue of combining the static and abstract, I redefined the classes as above, with a new error, also shown above.

  • 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-13T05:27:02+00:00Added an answer on May 13, 2026 at 5:27 am

    A static method cannot use $this to reference itself, as a static function can be utilized without instantiating the class, and therefore $this can’t be guaranteed to exist.

    The self keyword can be used to reference methods in the class tree. You’d want to implement it like this:

    public static function newEntry($post)      {  
        $t1 = self::funcA($post);
        $t2 = self::funcB();
    }
    

    However, be aware that there are issues surrounding Late Static Binding of class structures. PHP 5.3 can work differently than previous versions for this kind of scope resolution, so be sure to read up on it. If the parent/child structure doesn’t work properly for you, you can always reference a static method by exact classname as well, ie. Child::funcA.

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

Sidebar

Related Questions

If you have a base class defined as follows: public abstract class BaseMessageObject<T> where
I have the following base abstract class defined as: public abstract class BaseObject<T> :
I have the following class defined as a bean: @Repository(userDao) public class UserDao extends
In one C# project have a base class like this: public abstract class AbstractVersionedBase
I have an abstract base class with a TcpClient field: public abstract class ControllerBase
I have an abstract class: type TInterfaceMethod = class abstract public destructor Destroy; virtual;
I have an abstract base class and derived class: type TInterfaceMethod = class public
I have an abstract Class Monitor.java which is subclassed by a Class EmailMonitor.java .
I have an abstract class and I would like to use it quickly by
I have an abstract class defining a pure virtual method in c++: class Base

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.