亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

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;">如果沒有第二個參數(shù),系統(tǒng)默認(rèn)將其作為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>

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

scalarVal():如果$val->kindOf()=="scalar",則直接返回改對象的PHP對應(yīng)的值。
arrayMen(int $n):如果$val->kindOf()=="array",返回$val中第n個的值。
arraySize():如果$val->kindOf()=="array",返回$val的元素個數(shù)。

2.xmlrpcmsg
這個類提供一個向XML-RPC服務(wù)器發(fā)送請求的對象,客戶端發(fā)送xmlrpcmsg到服務(wù)器,服務(wù)器返回一個xmlrpcresp。

<span style="color: #008000;">//</span><span style="color: #008000;">請求服務(wù)器的examples.getStateName方法,參數(shù)是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>

相關(guān)函數(shù):
getNumParams():獲取xmlrpcmsg對象的參數(shù)的總數(shù)。
getParam(int $n):獲取xmlrpcmsg對象的第n個數(shù)的值。
3.xmlrpc_client
客戶端的基本類。

<span style="color: #008000;">//</span><span style="color: #008000;">在服務(wù)端www.test.com上面的interface.php路徑建立相關(guān)鏈接。    </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>

相關(guān)方法:
send($message,30):向服務(wù)端發(fā)送$message,超時時間是30秒。
setDebug(int $level):設(shè)置是否輸出調(diào)試信息,默認(rèn)是0即不輸出調(diào)試信息。$level1,打印服務(wù)端的HTTP頭信息及XML信息。$level2,同時打印服務(wù)端和客戶端的HTTP頭信息及XML信息。
4.xmlrpcresp
該類主要包含XML-RPC請求返回的結(jié)果。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;">在服務(wù)端生成一個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;">服務(wù)端出錯時,可以返回該類型。</span>

相關(guān)方法:
faultCode():客戶端獲取服務(wù)端返回的出錯代碼。
faultString():客戶端獲取服務(wù)端返回的出錯信息。
Value():客戶端獲取服務(wù)端返回的值。
5.xmlrpc_server
服務(wù)端的基本類。

<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()函數(shù)     </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>

四,一個實際例子
假設(shè)服務(wù)度是my.rpcserver.com,提供服務(wù)的路徑是interface.php,客戶端是my.test.com.

在服務(wù)度的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;">獲取第一個參數(shù)</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;">轉(zhuǎn)換成PHP對應(yīng)的值</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;">獲取第二個參數(shù)</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;">轉(zhuǎn)換成PHP對應(yīng)的值</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;">獲取第二個參數(shù)<br/><br/>    //轉(zhuǎn)換成PHP對應(yīng)的值</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>

在客戶端的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>

敢死隊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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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)

Object-Relational Mapping (ORM) Performance Tuning in PHP Object-Relational Mapping (ORM) Performance Tuning in PHP Jul 29, 2025 am 05:00 AM

Avoid N 1 query problems, reduce the number of database queries by loading associated data in advance; 2. Select only the required fields to avoid loading complete entities to save memory and bandwidth; 3. Use cache strategies reasonably, such as Doctrine's secondary cache or Redis cache high-frequency query results; 4. Optimize the entity life cycle and call clear() regularly to free up memory to prevent memory overflow; 5. Ensure that the database index exists and analyze the generated SQL statements to avoid inefficient queries; 6. Disable automatic change tracking in scenarios where changes are not required, and use arrays or lightweight modes to improve performance. Correct use of ORM requires combining SQL monitoring, caching, batch processing and appropriate optimization to ensure application performance while maintaining development efficiency.

Building Immutable Objects in PHP with Readonly Properties Building Immutable Objects in PHP with Readonly Properties Jul 30, 2025 am 05:40 AM

ReadonlypropertiesinPHP8.2canonlybeassignedonceintheconstructororatdeclarationandcannotbemodifiedafterward,enforcingimmutabilityatthelanguagelevel.2.Toachievedeepimmutability,wrapmutabletypeslikearraysinArrayObjectorusecustomimmutablecollectionssucha

Laravel raw SQL query example Laravel raw SQL query example Jul 29, 2025 am 02:59 AM

Laravel supports the use of native SQL queries, but parameter binding should be preferred to ensure safety; 1. Use DB::select() to execute SELECT queries with parameter binding to prevent SQL injection; 2. Use DB::update() to perform UPDATE operations and return the number of rows affected; 3. Use DB::insert() to insert data; 4. Use DB::delete() to delete data; 5. Use DB::statement() to execute SQL statements without result sets such as CREATE, ALTER, etc.; 6. It is recommended to use whereRaw, selectRaw and other methods in QueryBuilder to combine native expressions to improve security

css dark mode toggle example css dark mode toggle example Jul 30, 2025 am 05:28 AM

First, use JavaScript to obtain the user system preferences and locally stored theme settings, and initialize the page theme; 1. The HTML structure contains a button to trigger topic switching; 2. CSS uses: root to define bright theme variables, .dark-mode class defines dark theme variables, and applies these variables through var(); 3. JavaScript detects prefers-color-scheme and reads localStorage to determine the initial theme; 4. Switch the dark-mode class on the html element when clicking the button, and saves the current state to localStorage; 5. All color changes are accompanied by 0.3 seconds transition animation to enhance the user

python json loads example python json loads example Jul 29, 2025 am 03:23 AM

json.loads() is used to parse JSON strings into Python data structures. 1. The input must be a string wrapped in double quotes and the boolean value is true/false; 2. Supports automatic conversion of null→None, object→dict, array→list, etc.; 3. It is often used to process JSON strings returned by API. For example, response_string can be directly accessed after parsing by json.loads(). When using it, you must ensure that the JSON format is correct, otherwise an exception will be thrown.

go by example generics go by example generics Jul 29, 2025 am 04:10 AM

Go generics are supported since 1.18 and are used to write generic code for type-safe. 1. The generic function PrintSlice[Tany](s[]T) can print slices of any type, such as []int or []string. 2. Through type constraint Number limits T to numeric types such as int and float, Sum[TNumber](slice[]T)T safe summation is realized. 3. The generic structure typeBox[Tany]struct{ValueT} can encapsulate any type value and be used with the NewBox[Tany](vT)*Box[T] constructor. 4. Add Set(vT) and Get()T methods to Box[T] without

python parse date string example python parse date string example Jul 30, 2025 am 03:32 AM

Use datetime.strptime() to convert date strings into datetime object. 1. Basic usage: parse "2023-10-05" as datetime object through "%Y-%m-%d"; 2. Supports multiple formats such as "%m/%d/%Y" to parse American dates, "%d/%m/%Y" to parse British dates, "%b%d,%Y%I:%M%p" to parse time with AM/PM; 3. Use dateutil.parser.parse() to automatically infer unknown formats; 4. Use .d

css dropdown menu example css dropdown menu example Jul 30, 2025 am 05:36 AM

Yes, a common CSS drop-down menu can be implemented through pure HTML and CSS without JavaScript. 1. Use nested ul and li to build a menu structure; 2. Use the:hover pseudo-class to control the display and hiding of pull-down content; 3. Set position:relative for parent li, and the submenu is positioned using position:absolute; 4. The submenu defaults to display:none, which becomes display:block when hovered; 5. Multi-level pull-down can be achieved through nesting, combined with transition, and add fade-in animations, and adapted to mobile terminals with media queries. The entire solution is simple and does not require JavaScript support, which is suitable for large

See all articles