xp_listen

xp_listen($listener)

Registers a new listener.

Listeners are special objects that register each publically available method as an executing process using the method name.

Note

Public methods that are declared with a prepended underscore “_” are ignored.

Parameters:object – The object to register.
Return type:void

Example #1 Basic Usage

<?php

class My_Listener extends \XPSPL\Listener
{
    // Register a process for the foo signal.
    public function foobar($signal) {
        echo 'foobar';
    }
}

xp_listener(new My_Listener());

xp_emit(XP_SIG('foobar'));

The above code will output.

foobar
Read the Docs v: v5.0.1
Versions
latest
v5.0.1
v5.0.0
v4.0.1
v4.0.0
v3.1.1
v3.1.0
v3.0.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.