SetCallback — Registers a callback function


$plot->SetCallback($reason, $function, [$arg])


SetCallback registers a callback function. That is, it arranges for the caller-provided function to be called at a specific point or points inside PHPlot's internal processing.



A PHPlot-defined name for the callback. See Section 4.4.3, “Available Callbacks”.


The function to be called. This can be either the name of a function as a string, or a two-element array with an object class instance and method name. See Section 4.4.1, “Callbacks Application Interface” for more information.


An optional opaque argument passed-through to the callback function when PHPlot triggers the callback. If not supplied, the callback function will get a NULL argument.

Return Value

Returns True if the callback has been registered. Returns False on error. The only error condition is if the given callback reason is not valid. Note that the function name is not validated until the callback is triggered.


If a callback is already registered for the given reason, the new callback replaces the old one.

Refer to Section 4.4, “Callbacks” for more information on callbacks.


This function and the callbacks implementation were added in PHPlot-5.0.4 as an experimental feature. Callbacks were first documented in this manual as of PHPlot-5.0.5 and are no longer considered experimental. Logo

This version of the manual was produced for the PHPlot Sourceforge project web service site, which requires the logo on each page.

To download a logo-free copy of the manual, see the PHPlot project downloads area.