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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:38:20+00:00 2026-05-22T02:38:20+00:00

I find this really strange..could someone give an explanation? abstract class UIController{ public static

  • 0

I find this really strange..could someone give an explanation?

abstract class UIController{
   public static function exec($context,$vdo){
      return call_user_func(array($context, $vdo));   
   }
}

class UIControllerSettings extends UIController{
    protected function save(){
        return "saved\n";
    }
}

$controller = new UIControllerSettings();
echo UIController::exec($controller, 'save'); //<-- prints "saved"
echo $controller->save(); // <-- throws a fatal error 

Not sure it this makes sense;
shouldn’t both calls produce a fatal error??

Thanks in advance.

Update:

Here is the output:

$ php --version
PHP 5.3.3-1ubuntu9.5 with Suhosin-Patch (cli) (built: May  3 2011 00:48:48) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
$ php test.php 
saved
PHP Fatal error:  Call to protected method UIControllerSettings::save() from context '' in test.php on line 17
  • 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-22T02:38:21+00:00Added an answer on May 22, 2026 at 2:38 am

    Class members declared public can be accessed everywhere. Members declared protected can be accessed only within the class itself and by inherited and parent classes:

    http://php.net/manual/en/language.oop5.visibility.php.

    Since UIController::exec() is the right way to address the public static function, my guess is the call_use_func() is being processed as a call from within the class itself. On the other hand $controler->save() can’t be run because it’s a protected function.

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

Sidebar

Related Questions

really strange situation I got here. I have 2 classes. @Entity public class CategoryData
I couldn't really find this in Rails documentation but it seems like 'mattr_accessor' is
This is really just a best practices question... I find that When developing an
I know this is really dumb but I'm trying to find the advanced settings
I know this is really simple but I cant find the docs for this
Well this is a really weird issue, I really didn't find anything on this
This is probably really stupid but i can't find the problem with my code.
So this might be really simple, but I haven't been able to find any
This is a really simple question, but I can't seem to find the answer.
Have tried to find solutions for this and can't really come up with anything.

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.