Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<SoapServerSoapServer::addSoapHeader>
^SoapServerLast updated: Mon, 26 Oct 2026

SoapServer::addFunction

(PHP 5, PHP 7, PHP 8)

SoapServer::addFunction — Adds one or more functions to handle SOAP requests

Description

public function SoapServer::addFunction(array|string|int $functions): void

Exports one or more functions for remote clients

Parameters

functions

To export one function, pass the function name into this parameter as a string.

To export several functions, pass an array of function names.

To export all the functions, pass an array of function names.

As of PHP 8.4.0, passing an int value (including SOAP_FUNCTIONS_ALL) is deprecated. Use get_defined_functions() to retrieve all functions and pass them as an array instead.

Note:

functions must receive all input arguments in the same order as defined in the WSDL file (They should not receive any output parameters as arguments) and return one or more values. To return several values they must return an array with named output parameters.

Return Values

No value is returned.

Changelog

Version Description
8.4.0 Passing an int to SoapServer::addFunction(), including SOAP_FUNCTIONS_ALL, has been deprecated.

Examples

Example #1 SoapServer::addFunction() example

<?php

function echoString($inputString)
{
    return $inputString;
}

$server->addFunction("echoString");

function echoTwoStrings($inputString1, $inputString2)
{
    return array("outputString1" => $inputString1,
                 "outputString2" => $inputString2);
}
$server->addFunction(array("echoString", "echoTwoStrings"));

$functions = array_merge(...get_defined_functions());
$server->addFunction($functions);

?>

See Also


<SoapServerSoapServer::addSoapHeader>
^SoapServerLast updated: Mon, 26 Oct 2026