大家幫我看一下是什么問題?
php只回傳“用戶名”,但"aaa"顯示收不到、顯示不了。
因為還要傳輸圖片base64的資料,所以要用post方式。
vb
Set HttpClient = CreateObject("Microsoft.XMLHTTP")
HttpClient.Open "POST", "http://127.0.0.1/test.php", False
HttpClient.setRequestHeader "Content-Type", "text/xml; charset=gb2312"
HttpClient.send "f_name=aaa&f_code=123456"
<?php
//強制瀏覽器編碼
@header('Content-type: text/html;charset=gb2312');
//設定時區
date_default_timezone_set('PRC');
$s_name = trim($_POST['f_name']);
$s_code = $_POST['f_code'];
echo "用戶名" . $s_name;
?>
uj5u.com熱心網友回復:
post需要用這個headerHttpClient.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
uj5u.com熱心網友回復:
請問中文亂碼怎么解決?uj5u.com熱心網友回復:
如果全部站內的話,全用gb2312編碼統一好了,如果用了utf8,那在vb端就要轉碼了uj5u.com熱心網友回復:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<?php
//強制瀏覽器編碼
@header('Content-type: text/html;charset=gb2312');
//設定時區
date_default_timezone_set('PRC');
$s_name = trim($_POST['f_name']);
$s_code = $_POST['f_code'];
echo "用戶名" . $s_name;
?></body>
</html>
而且要注意你的PHP配置,default_charset = "gb2312"
uj5u.com熱心網友回復:
學習了 ,這個是VB net代碼吧uj5u.com熱心網友回復:
第三行 Content-Type 改一下HttpClient.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=gb2312"
uj5u.com熱心網友回復:
網上找的 URLEncode 函式Public Function URLEncode(ByVal strParameter As String) As String
Dim s As String
Dim I As Integer
Dim intValue As Integer
Dim TmpData() As Byte
s = ""
TmpData = StrConv(strParameter, vbFromUnicode)
For I = 0 To UBound(TmpData)
intValue = TmpData(I)
If (intValue >= 48 And intValue <= 57) Or _
(intValue >= 65 And intValue <= 90) Or _
(intValue >= 97 And intValue <= 122) Then
s = s & Chr(intValue)
ElseIf intValue = 32 Then
s = s & "+"
Else
s = s & "%" & Hex(intValue)
End If
Next I
URLEncode = s
End Function
第四行代碼改成
HttpClient.Send "f_name=" & URLEncode("中文") & "&f_code=123456"
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/42097.html
標籤:網絡編程
上一篇:建好的rbf神經網路可以通用嗎
