当前位置:网站首页>PHP receiving and sending data
PHP receiving and sending data
2022-06-23 13:51:00 【qq_ forty-five million nine hundred and eleven thousand five hu】
Write it at the front : Before reading this article , Hope readers have some php The basis of , You also need to know some knowledge about building websites
The client is usually through url Go to the server , After receiving the request from the client, the server returns the data required by the client to the client , There are naturally two problems :
1、 How the server receives requests sent by clients
Build a php file , Name it welcome.php, Write content in it
welcome <?php echo $_REQUEST["fname"]; ?>!<br>
Your age is <?php echo $_REQUEST["age"]; ?> year .
Create a folder under the root directory of the website as minipro, Put this file in this folder 
Then you access the connection through the browser http://127.0.0.1/minipro/welcome.php?fname=ericzeng&age=2
give the result as follows :
At this point, the data receiving is realized
2、 How the server returns data to the client , How the client receives
I used to be confused here , Later, it was found that only one was needed echo sufficient , See the following example :
We use the wechat applet to send requests to the local server ( It needs to be set up , Set up -> Project settings -> Check not verifying legal domain name https What? , Otherwise, a request can be made to the local server )
The applet file information is as follows :
index.js
Page({
data: {
t:"haode"
},
onLoad: function () {
this.setData({
t:"hello world!"});
wx.request(
{
url:"http://127.0.0.1/minipro/welcome.php?fname=ericzeng&age=2",
headers:{
'content-type':'application/json'
},
method:'GET',
success:res=>{
this.setData({
t:res.data
})
}
}
);
}
})
index.wxml
<view>
<view>{
{
t}}</view>
</view>
We still visit the previous link , You will find that the data on the web page appears on the applet page , Just process the data format locally ok 了 , Of course, the data we usually use json Format to transmit , stay php Use in json_encode() Method can convert data to json, Use to search for more specific content .

边栏推荐
- Detailed explanation of kubernetes log monitoring system architecture
- 如何正确计算导入Excel的行数(POI/NPOI)
- 前AMD芯片架构师吐槽,取消 K12 处理器项目是因为 AMD 怂了!
- quartus調用&設計D觸發器——仿真&時序波驗證
- Tinder security cooperates with Intel vPro platform to build a new pattern of software and hardware collaborative security
- 2-optical-2-electric cascaded optical fiber transceiver Gigabit 2-optical-2-electric optical fiber transceiver Mini embedded industrial mine intrinsic safety optical fiber transceiver
- leetcode:42.接雨水
- You call this shit MQ?
- Linear regression analysis of parent-child height data set
- Edge and IOT academic resources
猜你喜欢

How to write vite plug-ins

How did Tencent's technology bulls complete the overall cloud launch?

微信小程序之从底部弹出可选菜单

【课程预告】基于飞桨和OpenVINO 的AI表计产业解决方案 | 工业读表与字符检测

怎么手写vite插件

The way out after the development of Internet technology -- the birth of IVX

How to use androd gradle module dependency replacement

Detailed description of Modelsim installation steps

4E1 PDH optical transceiver 19 inch rack type single fiber transmission 20km E1 interface optical network optical transceiver

Loss, duplication and backlog of message queues
随机推荐
Cifar announces the second stage pan Canadian AI strategy
How to write vite plug-ins
Restcloud ETL resolves shell script parameterization
[deeply understand tcapulusdb technology] transaction execution of document acceptance
人脸注册,解锁,响应,一网打尽
Multi-Camera Detection of Social Distancing Reference Implementation
How deci and Intel can achieve up to 16.8x throughput improvement and +1.74% accuracy improvement on mlperf
如何打开/关闭chrome控制台调试时的时间戳?
What a talented company that can turn SAP system into a chicken rib!
16 channel HD-SDI optical transceiver multi channel HD-SDI HD video optical transceiver 16 channel 3g-sdi HD audio video optical transceiver
Intel ® extensions for pytorch* accelerate pytorch
构建英特尔 DevCloud
AAIG看全球6月刊(上)发布|AI人格真的觉醒了吗?NLP哪个细分方向最具社会价值?Get新观点新启发~
How to solve the task cache compilation problem caused by gradle build cache
Multi-Camera Detection of Social Distancing Reference Implementation
Face registration, unlock, respond, catch all
Is it safe for flush to open an account online? What should we pay attention to
Use openvinotm preprocessing API to further improve the reasoning performance of yolov5
32-way telephone +2-way Gigabit Ethernet 32-way PCM telephone optical transceiver supports FXO port FXS voice telephone to optical fiber
Detailed explanation of kubernetes log monitoring system architecture