当前位置:网站首页>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 .

边栏推荐
- Go写文件的权限 WriteFile(filename, data, 0644)?
- vulnhub靶机Os-hackNos-1
- Vulnhub target os-hacknos-1
- Generics, generic defects and application scenarios that 90% of people do not understand
- leetcode:242. Valid Letter ectopic words
- Deci 和英特尔如何在 MLPerf 上实现高达 16.8 倍的吞吐量提升和 +1.74% 的准确性提升
- Quarkus+saas multi tenant dynamic data source switching is simple and perfect
- How did Tencent's technology bulls complete the overall cloud launch?
- 20000 words + 30 pictures | MySQL log: what is the use of undo log, redo log and binlog?
- Tuikit audio and video low code solution navigation page
猜你喜欢

Hanyuan hi tech 1-channel gigabit optical port to 4-channel Gigabit Ethernet electrical port Gigabit 1-optical 4-electric optical fiber transceiver

Germancreditdata of dataset: a detailed introduction to the introduction, download and use of germancreditdata dataset

Go写文件的权限 WriteFile(filename, data, 0644)?

前AMD芯片架构师吐槽,取消 K12 处理器项目是因为 AMD 怂了!

Has aaig really awakened its AI personality after reading the global June issue (Part 1)? Which segment of NLP has the most social value? Get new ideas and inspiration ~

AI reference kit

Cloud native essay deep understanding of ingress
Detailed explanation of kubernetes log monitoring system architecture

通过 OpenVINO Model Server和 TensorFlow Serving简化部署

有向图D和E
随机推荐
MIT 6.031 reading5: version control learning experience
90%的人都不懂的泛型,泛型的缺陷和应用场景
OpenVINOTM 2022.1中AUTO插件和自动批处理的最佳实践
32-way telephone +2-way Gigabit Ethernet 32-way PCM telephone optical transceiver supports FXO port FXS voice telephone to optical fiber
微信小程序之从底部弹出可选菜单
Building Intel devcloud
What a talented company that can turn SAP system into a chicken rib!
IEEE Transaction期刊修改过程记录
Is it safe for flush to open an account online? What should we pay attention to
Simplify deployment with openvino model server and tensorflow serving
One way linked list implementation -- counting
Understand ADT and OOP
Online text entity extraction capability helps applications analyze massive text data
Cloud native essay deep understanding of ingress
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
腾讯的技术牛人们,是如何完成全面上云这件事儿的?
Gary Marcus wrote: three perspectives from linguists that AI researchers need to know
Principle analysis of three methods for exchanging two numbers
Actual combat | how to make a slam track truth acquisition device?
Modelsim 安装步骤详解