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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:23:56+00:00 2026-06-01T02:23:56+00:00

Lets say I have: class X { function a() { echo Hello, ; }

  • 0

Lets say I have:

class X
{
    function a()
    {
        echo "Hello, ";
    }
    function b()
    {
        echo "John!";
    }
}

and then

Y = new X();
Y->a();

but once the method a is called, I also want the method b called immediately after it (so it kind of listens(waits?) till the moment when a is called and finished), so the output is

Hello, John

Is it possible to do that, and how that should look?
And no, calling $this->b(); at the end of method a is NOT a solution to what I want to do 🙂 Thanks in advance 🙂

  • 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-01T02:23:57+00:00Added an answer on June 1, 2026 at 2:23 am

    You are searching for observer pattern. Read some example from the internet, you should be able to do what you are attempting.

    However, A very simple example of using observer pattern:

    class X
    {
        private $observer;
        public function __construct() {
            $this -> observer = new XObserver();
        }
    
        function a() {
            echo "Hello,";      
            $this -> observer -> aExecuted($this);
        }
    
        function b() {
            echo "John!";
        }
    }
    
    class XObserver {
    
        public function aExecuted($obj) {
            return $obj -> b(); 
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have: class Zebra{ public static function action(){ print 'I was called
Lets say I have a class like this in Java: public class Function {
Let's say I have a controller function with these lines: $this->load->view('stdHeader_view'); echo <div class='main'>;
lets say I have a class like so. var foodData = Class.create({ initialize: function()
Lets say I have these classes: class Foo { public $_data; public function addObject($obj)
Lets say i have a page called https://url.com/test and https://url.com/test2 class Test extends Application
Lets say I have a class like: class SomeClass{ function someAction($param1,$param2){} } Is there
Lets say we have this really trivial classes: class A { virtual int Function(int
I have a class that has a function, lets say class.php: class fun {
Lets say I have this class: function classA(n){ this.name = n } classA.prototype.getName =

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.