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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:08:20+00:00 2026-06-17T07:08:20+00:00

MApp uses $database_object . I got an error that I could not use it

  • 0

MApp uses $database_object. I got an error that I could not use it because it was private. However I changed it to protected and now it works. Note that in the class hierarchy MApp is above MAppAMAdder.

I thought that protected meant that child classes could use the resource not parent classes. Is PHP different from other languages or is my understanding of how inheritance works not correct?

MAppAdder Snippet

class MAppAMAdder extends MApp
{
    protected $database_object; // private will cause a fail.

MApp

abstract class MApp extends M
{
    protected function getID($pipe)
    {
        $temp = $this->database_object->_pdoQuery('single', 'pull_id_by_h_token',
            array($pipe['server']['smalls']['h_token']));
        $pipe['id'] = $temp['id'];
        return $pipe;
    }
    protected function addTweetTop($pipe, $comment)
    {
        $input = array( $pipe['server']['smalls']['h_token'], 
                        $pipe['server']['smalls']['picture'], 
                        $pipe['server']['smalls']['name'], 
                        $comment, 
                        time(), 
                        $pipe['server']['smalls']['h_file'] );
        $this->database_object->_pdoQuery( 'none', 'tweet_insert', $input);
        return $pipe;
    }
}

Error

Fatal error: Cannot access private property MAppTweet::$database_object in…

  • 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-17T07:08:22+00:00Added an answer on June 17, 2026 at 7:08 am

    In PHP protected means that parent classes can also access the property:

    Members declared protected can be accessed only within the class
    itself and by inherited and parent classes.

    You are correct in that this behavior is different from the “classical” behavior of strongly typed languages such as C++ and Java. In such languages (commonly called statically typed) the compiler prevents you from accessing class members in a way that is not provably correct by issuing a compile-time error. That’s why a parent class cannot speculatively access a member defined in a child class: there is no guarantee that the member will be there at runtime.

    On the other hand, PHP is dynamically typed and does let you refer to any member, even ones that do not exist at all (the access results to null in that case). The check for the existence of such a member is performed at runtime and can result in a wide array of outcomes (from nothing out of the ordinary to a runtime error in certain cases).

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

Sidebar

Related Questions

Trying to bind a field to a map of objects I got this error
I try mapp this table: CREATE TABLE AHQ.ReportConfigurationAttribute ( IdReportConfiguration integer NOT NULL, IdAttribute
What is the difference those? AddType x-mapp-php5 .php AddType application/x-httpd-php .php AddType x-httpd-php .php
I have a product table that has a many-to-many relation to itself (using a
I am trying to mapp pojo class to mongodb using morphia-0.93-SNAPSHOT.jar but it is
I have Silverlight application using NHibernate as a ORM. I have projects for Data(mapp
I got nearly no knowledge of haskell and tried to solve some Project Euler
With real examples and their use, can someone please help me understand: How to
I am making use of github project for integrating Instagram with Android My project
the stock svn that comes with OSX is 1.4.4 and I upgraded (through opencollab

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.