Home > Software engineering >  PHP call VB DLL files, access to the domain name is invalid?
PHP call VB DLL files, access to the domain name is invalid?

Time:11-08

'
vb DLL functionThe Public Function my_yuming ()
My_yuming=Request. ServerVariables (" Server_name ")
End the Function

The Public Function my_shu ()
My_shu=1 + 2
End the Function


PHP call the DLL file my_yuming function error
But call my_shu function is normal, display 3

Asp call the DLL file my_yuming function normal display

Can you tell me the PHP directly obtained in the DLL function domain information?



CodePudding user response:

The up
The up
The up
up

CodePudding user response:

00. PHP source code:
<? PHP

$obj=new COM (" zcy_gch_php. Zcy_class ");

//$output=$obj - & gt; My_shu ();
//echo $output;//display the results

$output=$obj - & gt; My_yuming ();
Echo $output;//display the results

?>

Error message:

Fatal error : Uncaught exception 'com_exception with message' & amp; lt; B& gt; Source: & amp; lt;/b& gt; Zcy_gch_php & amp; lt; Br/& amp; gt; & lt; B& gt; Description: & amp; lt;/b& gt; Not set a variable or object With block variables' in D: \ 00 ceshi \ WWW \ PHP: 8
The Stack trace:
# 0 D: \ 00 ceshi \ WWW \ PHP (8) : com - & amp; gt; My_yuming ()

CodePudding user response:

Try:
The Public Function my_yuming () as string

CodePudding user response:

Since tip not set the variable "object", that are Request this object was not created when PHP call?
In the DLL code try putting a judgment:
The Public Function my_yuming ()
If the Request is nothing then
My_yuming="Error."
The else
My_yuming=Request. ServerVariables (" Server_name ")
Endif
End Function

CodePudding user response:

The
refer to the original poster zcyzzzm response:
'
vb DLL functionThe Public Function my_yuming ()
My_yuming=Request. ServerVariables (" Server_name ")
End the Function

The Public Function my_shu ()
My_shu=1 + 2
End the Function


PHP call the DLL file my_yuming function error
But call my_shu function is normal, display 3

Asp call the DLL file my_yuming function normal display

Can you tell me the PHP directly obtained in the DLL function domain information?


Doubt is the string structure of VB6 PHP does not know, suggest using strconv converted to an array of bytes to return, PHP processing again,

CodePudding user response:

refer to fifth floor crispy big ice cream reply:
PHP does not know, doubt is the string of VB6 structure suggest using strconv into a byte array to return, PHP processing again,


I changed to:
The Public Function my_yuming ()
Aa=Request. ServerVariables (" Server_name ")
My_yuming="8888"
End the Function

PHP call or error:

Fatal error: Uncaught exception 'com_exception with message' Failed to create a COM object ` zcy_gch_php. Zcy_class ': ClassFactory cannot supply request category' in D: \ 00 ceshi \ WWW \ PHP: 6 Stack trace: # 0 D: \ 00 ceshi \ WWW \ PHP (6) : COM - & gt; Com (' zcy_gch_php. Zcy... ') # 1 {main} thrown in D:\www.hefei163.com \ WWW \ 00 PHP on line 6

If description: PHP can't call the function cannot use Request. ServerVariables (" Server_name ")

CodePudding user response:

refer to fifth floor crispy big ice cream reply:
PHP does not know, doubt is the string of VB6 structure suggest using strconv into a byte array to return, PHP processing again,

I changed to:
The Public Function my_yuming ()
Aa=Request. ServerVariables (" Server_name ")
My_yuming="8888"
End the Function

PHP call or error:

Fatal error: Uncaught exception 'com_exception with message' & lt; b> Source: & lt;/b> Zcy_gch_php & lt; Br/& gt; Description: & lt;/b> Not set a variable or object With block variables' in D: \ 00 ceshi \ WWW \ PHP: 11 Stack trace: # 0 D: \ 00 ceshi \ WWW \ PHP (11) : com - & gt; My_yuming () # 1 {main} thrown in D: \ 00 ceshi \ WWW \ PHP on line 11

If description: PHP can't call the function cannot use Request. ServerVariables (" Server_name ")
If you want to be a DLL call domain information, how to deal with

(note: 6th floor information is wrong, wrong is to register after each DLL to copy, that information is not registered in CSDN BBS reply can't rewrite, haha)





CodePudding user response:

The Public Function my_yuming ()
Aa=Request. ServerVariables (" Server_name ")
My_yuming=strconv (aa, vbfromunicode)
End the Function

Have a try

CodePudding user response:

refer to the eighth floor crispy big ice cream reply:
Public Function my_yuming ()
Aa=Request. ServerVariables (" Server_name ")
My_yuming=strconv (aa, vbfromunicode)
End the Function

Try


Tested, is still the same error message:

Fatal error: Uncaught exception 'com_exception with message' & lt; b> Source: & lt;/b> Zcy_gch_php & lt; Br/& gt; Description: & lt;/b> Not set a variable or object With block variables' in D: \ 00 ceshi \ WWW \ PHP: 11 Stack trace: # 0 D: \ 00 ceshi \ WWW \ PHP (11) : com - & gt; My_yuming () # 1 {main} thrown in D: \ 00 ceshi \ WWW \ PHP on line 11

CodePudding user response:

Not set a variable or object With block variable
Isn't com not normal load

CodePudding user response:

references to the tenth floor crispy big ice cream reply:
not set a variable or object With block variable
Whether haven't normal load com


The same DLL, asp can show normal
<%
Dim zcyzzzm
The Set zcyzzzm=Server. CreateObject (" zcy_gch_php. Zcy_class ")
Response. Write (zcyzzzm my_yuming ())
%> nullnull
  • Related