Php calls the com component parameter question text message PHP reference
I used php to develop the SMS cat interface, one of which is to read text messages, the code is as follows:
$ ObjSMS = new com ("alasun. alasunsms ");
$ ObjSMS-> commp ORT = $ port;
$ LngRes = $ objSMS-> OpenComm;
If ($ objSMS-> ReadMsgByIndex ($ Index, $ sNo, $ sCon, $ MsgCenterNo, array ($ dSendTime), $ lTimeZone) = 0)
{
Echo $ sNo. $ sCon ."
";
}
Parameter description:
$ Index: SMS serial number, which is the only input parameter.
$ SNo: SMS number, output parameter
$ SCon: text message content, output parameters
$ MsgCenterNo: SMS center, output parameter
$ DSendTime: SMS time, output parameter
$ LTimeZone: SMS time zone, output parameter
//////////////////////////////
// It is easy for me to use asp or other languages for processing. no matter whether input or output parameters are the same, the output parameters will have corresponding values after execution, but php cannot do anything, the test is as follows:
//// The first call
If ($ objSMS-> ReadMsgByIndex ($ Index, $ sNo, $ sCon, $ MsgCenterNo, $ dSendTime, $ lTimeZone) = 0)
// The following error occurs during this call.
Fatal error: Uncaught exception 'com _ exception' with message' Parameter 4: type mismatch.
'In E: \ AppServ \ www \ sms. php: 50
// 50 lines are the code above, because $ dSendTime is of the time type and the com component is written in c ++.
///// The second call. after reading the following information, the $ dSendTime parameter should be added with array. php itself has no datetime data type like other languages.
If ($ objSMS-> ReadMsgByIndex ($ Index, $ sNo, $ sCon, $ MsgCenterNo, array ($ dSendTime), $ lTimeZone) = 0)
// The following error occurs during this call, as if there is a problem with the reference.
Fatal error: Cannot pass parameter 5 by reference in E: \ AppServ \ www \ cron \ smsreceive. php on line 50
How can this problem be called? According to the following method, I add & in front of the next five output parameters, which is also the same error.
Reply to discussion (solution)
I searched for a text message about the cat.
Read short message (ReadMsgByIndex)
Function description: reads short messages at the specified position in the SIM card.
Parameter: iIndexNo Integer SMS No.
SNo string source number for receiving the SMS
SCon string received text message content
SMsgCenterNo string SMS center number
DSendTime date the time when the SMS is sent
Time zone in which iSendTimeZone Integer sends SMS messages
Return value: Long 0 is read successfully, and other reads fail.
DSendTime is a double-precision number, which corresponds to a php string of 8 characters.
But Parameter 4: The type does not match. does this 4th Parameter mean him?
Should it be sMsgCenterNo?
The error Fatal error: Cannot pass parameter 5 by reference is returned after this is changed to array ($ dSendTime ).
I searched for a text message about the cat.
Read short message (ReadMsgByIndex)
Function description: reads short messages at the specified position in the SIM card.
Parameter: iIndexNo Integer SMS No.
SNo string source number for receiving the SMS
SCon string received text message content
SMsgCenterNo string SMS center number
DSendTime date the time when the SMS is sent
Time zone in which iSendTimeZone Integer sends SMS messages
Return value: Long 0 is read successfully, and other reads fail.
DSendTime is a double-precision number, which corresponds to a php string of 8 characters.
But Parameter 4: The type does not match. does this 4th Parameter mean him?
Should it be sMsgCenterNo?
The error Fatal error: Cannot pass parameter 5 by reference is returned after this is changed to array ($ dSendTime ).
How can I pass a few parameters of Xiaohe to make it correct?
$ SMsgCenterNo
It is only a string-type parameter. after $ dSendTime is added with array, other errors are reported. it should indicate that this parameter type is started, but there are other problems.
Tested Again
$ SNo = "";
$ SCon = "";
$ MsgCenterNo = "+ 8613800200500 ";
$ DSendTime = array ();
$ LTimeZone = 0;
If ($ objSMS-> ReadMsgByIndex (intval ($ Index), $ sNo, $, $ MsgCenterNo, $ dSendTime, $ lTimeZone) = 0)
// The following error occurs:
B> Fatal error: Uncaught exception 'com _ exception' with message' Parameter 1: type mismatch.
The first parameter is the SMS serial number and number type. how can I prompt that parameter 1 is incorrect?
You give them strings of sufficient length.
You give them strings of sufficient length.
How does php define the length of a string parameter?
I tried it or the question of the time parameter, that is, the interface written in other languages. the parameter is of the datetime type, but I don't know how to define the parameter type in php?
PHP calls COM, which is generally an integer, string, or NULL. There are no other special types.
This post was last edited by xuzuning at 19:26:48
The dSendTime space corresponds to php "\ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00"
You actually transfer data, not
The dSendTime space corresponds to php "\ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00"
You actually transfer data, not
Yes, this is the output parameter, but the total return type error during execution. Other languages are simple. php does not know how to handle them.