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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:35:12+00:00 2026-06-10T02:35:12+00:00

The example comes from the book Professional PHP5 by Edward Lecky-Thompson. function __get($propertyName) {

  • 0

The example comes from the book “Professional PHP5” by Edward Lecky-Thompson.

  function __get($propertyName) {
  if(!array_key_exists($propertyName, $this->propertyTable))
     throw new Exception("Błędna własność \"$propertyName\"!");

  if(method_exists($this, 'get' . $propertyName)) {
     return call_user_func(array($this, 'get' . $propertyName));
  } else {
     return $this->data[$this->propertyTable[$propertyName]];
  }
}

Can somebody please explain what happens exactly step-by-step in the call_user_func function?

On php.net I’ve read that the first parameter is a function to be called and the remaining parameters are passed to that function as its parameters.

On php.net there were simple examples and I had no problem understanding them. However I don’t get it why in the above example there is an array, and why $this as the first element of the array?

P.S.
I found a similar question on stackoverflow, and I understand what the code is supposed to do but I don’t understand fully why what’s written works.

Here’s the link to the similar question:
PropertyObject

  • 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-10T02:35:14+00:00Added an answer on June 10, 2026 at 2:35 am

    The two-part array is PHP’s informal formal convention of passing the method of a specific object as a callback/callable. See http://php.net/manual/en/language.types.callable.php for details.

    array($this, 'getFoo') simply stands for the getFoo method of the $this object.

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

Sidebar

Related Questions

So, this example comes right from MSDN. http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readelementcontentasbase64.aspx Pretty much the only thing I
Check this example before reading the question - http://www.sqlfiddle.com/#!2/fcf3e/8 The following data comes from
This example is taken from the Linux System Programming book, page 88. Code: http://pastebin.com/mEfmHbPP
Higher rank types look like great fun. From the Haskell wikibook comes this example:
My application receives email from users. A response from gmail, for example, comes in
This is an example XML file that would come from the Android Client. <test>
For example, this method from NSCalendar takes a bitmask: - (NSDate *)dateByAddingComponents:(NSDateComponents *)comps toDate:(NSDate
I was going through an example from the Programming in Ruby book: def fib_up_to(max)
I am wondering why I can't compile an example from book. I simplify the
The example is from a book. Table heading,Odd,even rows have different colors. It selects

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.