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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:43:23+00:00 2026-06-12T04:43:23+00:00

i have multiple php classes // a Base class abstract class Base_Page { protected

  • 0

i have multiple php classes

// a Base class
abstract class Base_Page {
   protected static $config = array(
      'status' => 'int',
   );
}
// an inheriting class
class Page extends Base_Page{
   protected static $config = array(
      'title' => 'varchar',
      'description' => 'text',
);
// and one more level of inheritance
class Page_Redirect extends Base_Page {
   protected static $config = array(
      'href' => 'http://domain.com',
   );
}

now id’d like to do this:

$page_redirect = new Page_Redirect();
$page_redirect->getConfig(); // which i assume to be implemented (this is my problem)
// should return:
// array(
//    'status' => 'int',
//    'title' => 'varchar',
//    'description' => 'text',
//    'href' => 'http://domain.com',
// )

Due to the fact that the variable gets overwrote by the extending class a dont’t get how to accomplish this. Thanks for your look at it.

  • 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-06-12T04:43:24+00:00Added an answer on June 12, 2026 at 4:43 am

    You cannot do this with a bare property. It would be much better to use methods instead:

    abstract class Base_Page {
       protected function getConfig() {
           return array('status' => 'int');
       }
    }
    
    // an inheriting class
    class Page extends Base_Page{
       protected function getConfig() {
           return array(
              'title' => 'varchar',
              'description' => 'text',
           ) + parent::getConfig();
       }
    }
    
    // and one more level of inheritance
    class Page_Redirect extends Base_Page {
       protected function getConfig() {
           return array(
              'href' => 'http://domain.com',
           ) + parent::getConfig();
       }
    }
    

    Of course now you have lost the ability to get the configuration statically, but it’s highly likely that this does not matter. If it does (i.e. you need to know the configuration without having an instance at hand, and it is meaningless to create one on a whim) then the code needs further refactoring.

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

Sidebar

Related Questions

I have an html document with multiple commented-out PHP arrays, e.g.: <!-- Array (
I have multiple PHP classes with approximately 20 functions each all in one PHP
Writing a PHP app and have several classes that only have static methods (no
I have a class hierarchy in PHP 5.2.9 . The base class has a
I have a simple question regarding PHP Classes. Multiple times I have seen other
I have multiple web applications (PHP) which are being served to different customers from
I have been reading up on multiple PHP frameworks, especially the Zend Framework but
Working on an AJAX website (HTML,CSS,JavaScript, AJAX, PHP, MySQL). I have multiple javascript functions
I have a multiple language website, and I use a php get variable to
Im getting an error with my SQL queries in PHP. I have tried multiple

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.