PHP 8.5.0 RC4 available for testing

GearmanJob::__construct

(PECL gearman >= 0.5.0)

GearmanJob::__constructCreate a GearmanJob instance

Description

public GearmanJob::__construct()

Creates a GearmanJob instance representing a job the worker is to complete.

Parameters

This function has no parameters.

Return Values

A GearmanJob object.

add a note

User Contributed Notes 1 note

up
2
liv_romania at yahoo dot com
10 years ago
Usually you will not need to create a GearmanJob object. The GearmanJob instance will be passed to a registered function with the job server when GearmanWorker::addFunction is used:

<?php
/ create the worker
$worker= new GearmanWorker();

/ add the default job server (localhost)
$worker->addServer('127.0.0.1', 4730);

/ define a variable to hold application data
$count = 0;

/ add the reverse function
$worker->addFunction('reverse', 'my_reverse_function', $count);

/ start the worker listening for job submissions
while ($worker->work());

function
my_reverse_function(GearmanJob $job, &$count)
{
$count++;

return
$count . ': ' . strrev($job->workload()) . "\n";
}
?>
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant