PHP 8.5.4 Released!

SoapServer::addFunction

(PHP 5, PHP 7, PHP 8)

SoapServer::addFunctionSOAP リクエストによって処理される単一もしくはいくつかの関数を追加する

説明

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

リモートクライアント用に単一もしくは複数の関数をエクスポートします。

パラメータ

functions

単一の関数をエクスポートするには、 このパラメータに文字列として関数名を渡してください。

いくつかの関数をエクスポートするには、関数名の配列を渡してください。

全ての関数をエクスポートするには、関数名の配列を渡してください。

PHP 8.4.0 以降、int 値 (SOAP_FUNCTIONS_ALL を含む)を渡すことは非推奨になりました。 get_defined_functions() を使って全ての関数を取得し、 配列として渡してください。

注意:

functions は、全ての入力引数を WSDL ファイルで定義されている順序と同じ順序で受け取る必要があり (これらの関数は出力パラメータを引数として受け取ることはありません) 、一つまたは複数の値を返す必要があります。 複数の値を返すには、名前付き出力パラメータの配列を返す必要があります。

戻り値

値を返しません。

変更履歴

バージョン 説明
8.4.0 SoapServer::addFunction()int を渡すこと (SOAP_FUNCTIONS_ALL を含む)は非推奨になりました。

例1 SoapServer::addFunction() の例

<?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);

?>

参考

add a note

User Contributed Notes 1 note

up
11
dotpointer at gmail dot com
18 years ago
Be careful with SOAP_FUNCTIONS_ALL, as it adds ALL availiable PHP functions to your server.

This can be a potential security threat, imagine clients doing this:

echo $client->file_get_contents("c:\\my files\\my_passwords.doc");

And voila, they have the contents of your file my_passwords.doc.
To Top