SoapServer::addFunction
(PHP 5, PHP 7, PHP 8)
SoapServer::addFunction — 添加一个或多个函数来处理 SOAP 请求
参数
functions
-
导出一个函数,将函数名作为字符串传递给这个参数。
导出多个函数,将一组函数名作为数组传递。
导出所有函数,传递特殊常量
SOAP_FUNCTIONS_ALL
.注意:
functions
接收的所有输入参数必须同时和 WSDL 文件中定义的顺序一样(它们不应该接收任何输出变量作为参数)并且返回一个或多个值。如果要返回多个值,它们必须返回一组被命名的输出参数作为数组。
返回值
没有返回值。
示例
示例 #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"));
$server->addFunction(SOAP_FUNCTIONS_ALL);
?>
参见
- SoapServer::__construct() - SoapServer constructor
- SoapServer::setClass() - Sets the class which handles SOAP requests
+添加备注
用户贡献的备注 1 note
dotpointer at gmail dot com ¶
17 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.
备份地址:http://www.lvesu.com/blog/php/soapserver.addfunction.php