Home php教程 php手册 Introduction and use of XML-RPC for PHP

Introduction and use of XML-RPC for PHP

May 26, 2018 pm 02:15 PM
php rpc xml code Open source Introduction programming programming language software development

1. What is XML-RPC?
XML-RPC is a format designed by Userland Software company: it is a format designed to use HTTP protocol transfers XML format file to obtain remote procedure call (Remote Procedure Call) transmission method. The official website is www.xmlrpc.com.

There is a PHP XML-RPCFramework(Collection of classes) is used to use PHP Language to write XML-RPC client and server. The current stable release version is 2.2, and the download address of is http://sourceforge.net/projects/phpxmlrpc/files/phpxmlrpc/2.2.2/xmlrpc -2.2.2.tar.gz/download. In addition, you can also find other s language

XML-RPCwww.xmlrpc.com 🎜> list, such as Perl, Python. This article will introduce the use of XML-RPC for PHP

class library. 2. System Operation Requirements

The design goals of this class library are scalability and backward compatibility. Therefore, it supports most existing PHP

versions. The minimum required PHP version is 4.2. This library provides a compatibility layer to support PHP 4.0.5 and 4.1. Of course, the official recommendation is to use PHP 5.0 or higher.

Note that if you want to use SSL or HTTP 1.1 to communicate with the remote server, you must put "CURL” extension is compiled into PHP.

In addition, the native "xmlrpc" extension that comes with PHP is introduced here The XML-RPC class library is not the same thing, so there is no need to compile it into PHP.

3. Introduction to related classes

1.xmlrpcval

There are six basic types in XML-RPC Two composite types, the basic types are: int, boolean, string , double, dateTime.iso8601, base6, the composite type is: array, struct. The function of Xmlrpcval is to convert the types in PHP into these types and put them into XML-RPC for transmission.


<span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">123</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">int</span><span style="color: #000000;">"</span><span style="color: #000000;">);   </span><span style="color: #008000;">//</span><span style="color: #008000;">将123作为XML-RPC int类型</span><span style="color: #008000;"><br/></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">123</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">string</span><span style="color: #000000;">"</span><span style="color: #000000;">); </span><span style="color: #008000;">//</span><span style="color: #008000;">将123作为XML-RPC string类型</span><span style="color: #008000;"><br/></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">123</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">如果没有第二个参数,系统默认将其作为string类型</span><span style="color: #008000;"><br/></span><span style="color: #000000;"><br/></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(    </span><span style="color: #008000;">//</span><span style="color: #008000;">XML-RPC array类型   </span><span style="color: #008000;"><br/></span><span style="color: #0000ff;">array</span><span style="color: #000000;">(<br/>       </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">"</span><span style="color: #000000;">string1</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;">    <br/>       </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">"</span><span style="color: #000000;">string2</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>       </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">"</span><span style="color: #000000;">string3</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">array</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br/> <br/></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(    </span><span style="color: #008000;">//</span><span style="color: #008000;">XML-RPC struct类型        </span><span style="color: #008000;"><br/></span><span style="color: #0000ff;">array</span><span style="color: #000000;">(    </span><span style="color: #000000;">"</span><span style="color: #000000;">name</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">"</span><span style="color: #000000;">codebean</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">string</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>    </span><span style="color: #000000;">"</span><span style="color: #000000;">age</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">34</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">int</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>                </span><span style="color: #000000;">"</span><span style="color: #000000;">address</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(        <br/>                           </span><span style="color: #0000ff;">array</span><span style="color: #000000;">(                          </span><span style="color: #000000;">"</span><span style="color: #000000;">street</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcva(</span><span style="color: #000000;">"</span><span style="color: #000000;">xiaoyinxilu</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">string</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">city</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">"</span><span style="color: #000000;">beijing</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">string</span><span style="color: #000000;">"</span><span style="color: #000000;">)        )</span><span style="color: #000000;">,</span><span style="color: #000000;">        <br/>                          </span><span style="color: #000000;">"</span><span style="color: #000000;">struct</span><span style="color: #000000;">"</span><span style="color: #000000;">))</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/></span><span style="color: #000000;">"</span><span style="color: #000000;">struct</span><span style="color: #000000;">"</span><span style="color: #000000;">);</span>
Copy after login

Related methods:
kindOf(): Returns the basic type of the object: "struct", "array", "scalar".

scalarVal():如果$val->kindOf()=="scalar",则直接返回改对象的PHP对应的值。
arrayMen(int $n):如果$val->kindOf()=="array",返回$val中第n个的值。
arraySize():如果$val->kindOf()=="array",返回$val的元素个数。

2.xmlrpcmsg
这个类提供一个向XML-RPC服务器发送请求的对象,客户端发送xmlrpcmsg到服务器,服务器返回一个xmlrpcresp

<span style="color: #008000;">//</span><span style="color: #008000;">请求服务器的examples.getStateName方法,参数是123</span><span style="color: #008000;"><br/></span><span style="color: #800080;">$message</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcmsg(</span><span style="color: #000000;">"</span><span style="color: #000000;">examples.getStateName</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #0000ff;">array</span><span style="color: #000000;">(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">123</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">int</span><span style="color: #000000;">"</span><span style="color: #000000;">)));</span>
Copy after login

相关函数:
getNumParams():获取xmlrpcmsg对象的参数的总数。
getParam(int $n):获取xmlrpcmsg对象的第n个数的值。
3.xmlrpc_client
客户端的基本类。

<span style="color: #008000;">//</span><span style="color: #008000;">在服务端www.test.com上面的interface.php路径建立相关链接。    </span><span style="color: #008000;"><br/></span><span style="color: #800080;">$client</span><span style="color: #000000;">=</span><span style="color: #000000;"> nw xmlrpc_client(</span><span style="color: #000000;">"</span><span style="color: #000000;">/interface.php</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">ww.test.com</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">80</span><span style="color: #000000;">);</span>
Copy after login

相关方法:
send($message,30):向服务端发送$message,超时时间是30秒。
setDebug(int $level):设置是否输出调试信息,默认是0即不输出调试信息。$level1,打印服务端的HTTP头信息及XML信息。$level2,同时打印服务端和客户端的HTTP头信息及XML信息。
4.xmlrpcresp
该类主要包含XML-RPC请求返回的结果。Xmlrpc_clientsend方法返回该类型。

<span style="color: #0000ff;">new</span><span style="color: #000000;">  xmlrpcresp(xmlrpcval </span><span style="color: #800080;">$val</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">在服务端生成一个xmlrpcresp对象</span><span style="color: #008000;"><br/></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcresp(</span><span style="color: #000000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">int </span><span style="color: #800080;">$errcode</span><span style="color: #000000;">,</span><span style="color: #0000ff;">string</span><span style="color: #800080;">$err_string</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">服务端出错时,可以返回该类型。</span>
Copy after login

相关方法:
faultCode():客户端获取服务端返回的出错代码。
faultString():客户端获取服务端返回的出错信息。
Value():客户端获取服务端返回的值。
5.xmlrpc_server
服务端的基本类。

<span style="color: #0000ff;">function</span><span style="color: #000000;"> test(</span><span style="color: #800080;">$xmlrpcval</span><span style="color: #000000;">){<br/>  </span><span style="color: #0000ff;">return</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcresp(</span><span style="color: #800080;">$val</span><span style="color: #000000;">);<br/>}<br/><br/></span><span style="color: #008000;">//</span><span style="color: #008000;">客户端可以访问examples.myTest来实际访问test()函数     </span><span style="color: #008000;"><br/></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpc_server(        <br/>  </span><span style="color: #0000ff;">array</span><span style="color: #000000;">(            <br/>     </span><span style="color: #000000;">"</span><span style="color: #000000;">examples.myTest</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #0000ff;">array</span><span style="color: #000000;">(</span><span style="color: #000000;">"</span><span style="color: #000000;">function</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #000000;">"</span><span style="color: #000000;">test</span><span style="color: #000000;">"</span><span style="color: #000000;">)    <br/>));</span>
Copy after login

四,一个实际例子
假设服务度是my.rpcserver.com,提供服务的路径是interface.php,客户端是my.test.com.

在服务度的interface.php中:

<span style="color: #000000;"><?</span><span style="color: #000000;">php<br/></span><span style="color: #0000ff;">include</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">./lib/xmlrpc.inc</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">;<br/></span><span style="color: #0000ff;">include</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">./lib/xmlrpcs.inc</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">;<br/><br/></span><span style="color: #0000ff;">function</span><span style="color: #000000;"> foo(</span><span style="color: #800080;">$xmlrpcmsg</span><span style="color: #000000;">){<br/>    </span><span style="color: #800080;">$par1</span><span style="color: #000000;">=</span><span style="color: #800080;">$xmlrpcmsg</span><span style="color: #000000;">-></span><span style="color: #000000;">getParam(</span><span style="color: #000000;">0</span><span style="color: #000000;">);    </span><span style="color: #008000;">//</span><span style="color: #008000;">获取第一个参数</span><span style="color: #008000;"><br/></span><span style="color: #800080;">$val1</span><span style="color: #000000;">=</span><span style="color: #800080;">$par1</span><span style="color: #000000;">-></span><span style="color: #000000;">scalarval();            </span><span style="color: #008000;">//</span><span style="color: #008000;">转换成PHP对应的值</span><span style="color: #008000;"><br/></span><span style="color: #000000;">    <br/>    </span><span style="color: #800080;">$par2</span><span style="color: #000000;">=</span><span style="color: #800080;">$xmlrpcmsg</span><span style="color: #000000;">-></span><span style="color: #000000;">getParam(</span><span style="color: #000000;">1</span><span style="color: #000000;">);    </span><span style="color: #008000;">//</span><span style="color: #008000;">获取第二个参数</span><span style="color: #008000;"><br/></span><span style="color: #800080;">$val2</span><span style="color: #000000;">=</span><span style="color: #800080;">$par2</span><span style="color: #000000;">-></span><span style="color: #000000;">scalarval();            </span><span style="color: #008000;">//</span><span style="color: #008000;">转换成PHP对应的值</span><span style="color: #008000;"><br/></span><span style="color: #000000;">    <br/>    </span><span style="color: #800080;">$par3</span><span style="color: #000000;">=</span><span style="color: #800080;">$xmlrpcmsg</span><span style="color: #000000;">-></span><span style="color: #000000;">getParam(</span><span style="color: #000000;">2</span><span style="color: #000000;">);    </span><span style="color: #008000;">//</span><span style="color: #008000;">获取第二个参数<br/><br/>    //转换成PHP对应的值</span><span style="color: #008000;"><br/></span><span style="color: #0000ff;">for</span><span style="color: #000000;">(</span><span style="color: #800080;">$i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">; </span><span style="color: #800080;">$i</span><span style="color: #000000;"><</span><span style="color: #800080;">$par3</span><span style="color: #000000;">-></span><span style="color: #000000;">arraySize(); </span><span style="color: #800080;">$i</span><span style="color: #000000;">++</span><span style="color: #000000;">){<br/>        </span><span style="color: #800080;">$v</span><span style="color: #000000;">=</span><span style="color: #800080;">$par3</span><span style="color: #000000;">-></span><span style="color: #000000;">arrayMem(</span><span style="color: #800080;">$i</span><span style="color: #000000;">);<br/>        </span><span style="color: #800080;">$val</span><span style="color: #000000;">[] </span><span style="color: #000000;">=</span><span style="color: #800080;">$v</span><span style="color: #000000;">-></span><span style="color: #000000;">scalarVal()</span><span style="color: #000000;">.</span><span style="color: #000000;">"</span><span style="color: #000000;"><br/></span><span style="color: #000000;">"</span><span style="color: #000000;">;<br/>    }<br/>    <br/>    </span><span style="color: #800080;">$msg1</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #008080;">strrev</span><span style="color: #000000;">(</span><span style="color: #800080;">$val1</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">string</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br/>    </span><span style="color: #800080;">$msg2</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #008080;">strrev</span><span style="color: #000000;">(</span><span style="color: #800080;">$val2</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">int</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br/><br/>    </span><span style="color: #800080;">$msg</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #0000ff;">array</span><span style="color: #000000;">(</span><span style="color: #800080;">$msg1</span><span style="color: #000000;">,</span><span style="color: #800080;">$msg2</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">array</span><span style="color: #000000;">"</span><span style="color: #000000;">);        </span><span style="color: #008000;">//</span><span style="color: #008000;">返回一个array</span><span style="color: #008000;"><br/></span><span style="color: #000000;">    <br/>    </span><span style="color: #0000ff;">return</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcresp(</span><span style="color: #800080;">$msg</span><span style="color: #000000;">);<br/>}<br/><br/></span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpc_server(<br/>    </span><span style="color: #0000ff;">array</span><span style="color: #000000;">(<br/>        </span><span style="color: #000000;">"</span><span style="color: #000000;">example.test</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #0000ff;">array</span><span style="color: #000000;">(</span><span style="color: #000000;">"</span><span style="color: #000000;">function</span><span style="color: #000000;">"</span><span style="color: #000000;">=></span><span style="color: #000000;">"</span><span style="color: #000000;">foo</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>    )<br/>);<br/></span><span style="color: #000000;">?></span>
Copy after login

在客户端的client.php中:

<span style="color: #000000;"><?</span><span style="color: #000000;">php <br/></span><span style="color: #0000ff;">include</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">./lib/xmlrpc.inc</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">;<br/></span><span style="color: #800080;">$params</span><span style="color: #000000;">=</span><span style="color: #0000ff;">array</span><span style="color: #000000;">(<br/>    </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">"</span><span style="color: #000000;">hello rpc</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">string</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>    </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">123</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">int</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>    </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval( <br/>        </span><span style="color: #0000ff;">array</span><span style="color: #000000;">(<br/>            </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">"</span><span style="color: #000000;">test</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">string</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>            </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcval(</span><span style="color: #000000;">456</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">int</span><span style="color: #000000;">"</span><span style="color: #000000;">)<br/>        )</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>        </span><span style="color: #000000;">"</span><span style="color: #000000;">array</span><span style="color: #000000;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">,</span><span style="color: #000000;"><br/>);<br/><br/></span><span style="color: #800080;">$message</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpcmsg(</span><span style="color: #000000;">"</span><span style="color: #000000;">example.test</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$params</span><span style="color: #000000;">);<br/></span><span style="color: #800080;">$client</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> xmlrpc_client(</span><span style="color: #000000;">"</span><span style="color: #000000;">/interface.php</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">my.rpcserver.com</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">80</span><span style="color: #000000;">&#39;</span><span style="color: #000000;">);<br/></span><span style="color: #008000;">//</span><span style="color: #008000;">$client->setDebug(2);</span><span style="color: #008000;"><br/></span><span style="color: #800080;">$res</span><span style="color: #000000;">=</span><span style="color: #800080;">$client</span><span style="color: #000000;">-></span><span style="color: #000000;">send(</span><span style="color: #800080;">$message</span><span style="color: #000000;">,</span><span style="color: #000000;">30</span><span style="color: #000000;">);<br/><br/></span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #800080;">$res</span><span style="color: #000000;">-></span><span style="color: #000000;">faultCode()){<br/>    </span><span style="color: #800080;">$v</span><span style="color: #000000;">=</span><span style="color: #800080;">$res</span><span style="color: #000000;">-></span><span style="color: #000000;">value();<br/>    </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(</span><span style="color: #800080;">$i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">; </span><span style="color: #800080;">$i</span><span style="color: #000000;"><</span><span style="color: #800080;">$v</span><span style="color: #000000;">-></span><span style="color: #000000;">arraySize(); </span><span style="color: #800080;">$i</span><span style="color: #000000;">++</span><span style="color: #000000;">){<br/>        </span><span style="color: #800080;">$vv</span><span style="color: #000000;">=</span><span style="color: #800080;">$v</span><span style="color: #000000;">-></span><span style="color: #000000;">arrayMem(</span><span style="color: #800080;">$i</span><span style="color: #000000;">);<br/>        </span><span style="color: #0000ff;">echo</span><span style="color: #800080;">$vv</span><span style="color: #000000;">-></span><span style="color: #000000;">scalarVal()</span><span style="color: #000000;">.</span><span style="color: #000000;">"</span><span style="color: #000000;"><br/></span><span style="color: #000000;">"</span><span style="color: #000000;">;<br/>    }<br/>}</span><span style="color: #0000ff;">else</span><span style="color: #000000;">{<br/>    </span><span style="color: #0000ff;">echo</span><span style="color: #800080;">$res</span><span style="color: #000000;">-></span><span style="color: #000000;">faultcode()</span><span style="color: #000000;">.</span><span style="color: #000000;">"</span><span style="color: #000000;">:</span><span style="color: #000000;">"</span><span style="color: #000000;">.</span><span style="color: #800080;">$res</span><span style="color: #000000;">-></span><span style="color: #000000;">faultString()</span><span style="color: #000000;">.</span><span style="color: #000000;">"</span><span style="color: #000000;"><br/></span><span style="color: #000000;">"</span><span style="color: #000000;">;<br/>}<br/></span><span style="color: #000000;">?></span>
Copy after login

敢死队2在线观看

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

Explain the match expression (PHP 8 ) and how it differs from switch. Explain the match expression (PHP 8 ) and how it differs from switch. Apr 06, 2025 am 12:03 AM

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? Apr 07, 2025 am 12:02 AM

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

See all articles