最近因工作需要,要为一款手机游戏弄个管理游戏排行榜的服务器,经过同学介绍,认为使用php来开发比较简单,所以就临时去学了php的基础语法和网上查了很多关于如何开发服务器的资料。
在这里本人谈谈我自己做服务器过程中遇到的问题,希望跟我一样临时需要开发php服务器的新手可以获得帮助,至于高手,你就无视我吧。
网上找的很多资料都是讲php如何模拟发送http请求的,很少有关于服务器如何获取客户端请求的资料,或许经过系统学习的都知道了,但是对于本人这种临时学习的,还真是个硬伤。
经过我查找的资料 php做的服务器接受客户端的数据可以通过$_POST,$_GET,$_REQUEST来获取。 客户端需要用对应的$_post,$_get 来提交数据,$_REQUEST似乎都可以。
至于$_POST,$_GET的区别,百度上太多了 你可以自己找找
$_POST,$_GET返回的就是你客户端传过来的参数,你可以通过处理这些参数来完成功能,至于你想返回数据给客户端,只需要echo就行了
如果客户端使用get方式发送的请求,想获取数据很简单,只需要使用$_SERVER['QUERY_STRING'] 即可获取,信息来源于http://hi.baidu.com/iigyphfsjfgjkye/item/f180b2fbc5aa18ee1b111fc1 更多信息自己查看吧
我这次做的php服务器,不知道是什么原因,用$_POST,$_GET,$_REQUEST不能获取到数据。 所以找了$GLOBALS[$HTTP_RAW_POST_DATA]和file_get_contents("http://input")来获取数据
上面两个方式都能获取客户端post过来的请求 第一个听说似乎不能收一种数据,忘了
我使用的是第二个 $request = file_get_contents("http://input") 就得到了客户端post过来的参数了。
在这里介绍一种软件Fidder,百度即能下载。这软件能代替客户端来发送get,post等等等方式的请求,能够测试你服务器是否能收到客户端的请求。
回复讨论(解决方案)
lz想表达什么意思。
不管怎么样都要赞一个,希望以后会有更多自己的心得分享给大家
感觉每个帖子都能帮助到我,楼主的经验非常好
楼主这是对自己学习的总结吗?
用$_POST,$_GET,$_REQUEST不能获取到数据。 所以找了$GLOBALS[$HTTP_RAW_POST_DATA]和file_get_contents("http://input")来获取数据。
你的数据是二进制流吗?
$_POST:通过 HTTP POST 方法传递的变量组成的数组。是自动全局变量。
$GLOBALS['HTTP_RAW_POST_DATA'] :总是产生 $HTTP_RAW_POST_DATA 变量包含有原始的 POST 数据。此变量仅在碰到未识别 MIME 类型的数据时产生。$HTTP_RAW_POST_DATA 对于 enctype="multipart/form-data" 表单数据不可用。
也就是说基本上$GLOBALS['HTTP_RAW_POST_DATA'] 和 $_POST是一样的。
但是如果post过来的数据不是PHP能够识别的,你可以用 $GLOBALS['HTTP_RAW_POST_DATA']来接收,比如 text/xml 或者 soap 等等。
补充说明: PHP默认识别的数据类型是application/x-www.form-urlencoded标准的数据类型
我还以为LZ是要用PHP开发一个类似Apache的Web服务器呢,原来。。。。
我觉得这应该是软文推广。。。看到最后一行秒懂。。好吧,我想多了。
lz想表达什么意思。 我只是分享一下我自己遇到的问题而已 或许能帮到跟我一样临时需要的人咯……
楼主这是对自己学习的总结吗? 可以算吧,不过我做完这服务器 以后或许也不会使用php呢 毕竟是临时需要而已嘛……
用$_POST,$_GET,$_REQUEST不能获取到数据。 所以找了$GLOBALS[$HTTP_RAW_POST_DATA]和file_get_contents("http://input")来获取数据。
你的数据是二进制流吗?
$_POST:通过 HTTP POST 方法传递的变量组成的数组。是自动全局变量。
$GLOBALS['HTTP_RAW_POST_DATA'] :总是产生 $HTTP_RAW_POST_DATA 变量包含有原始的 POST 数据。此变量仅在碰到未识别 MIME 类型的数据时产生。$HTTP_RAW_POST_DATA 对于 enctype="multipart/form-data" 表单数据不可用。
也就是说基本上$GLOBALS['HTTP_RAW_POST_DATA'] 和 $_POST是一样的。
但是如果post过来的数据不是PHP能够识别的,你可以用 $GLOBALS['HTTP_RAW_POST_DATA']来接收,比如 text/xml 或者 soap 等等。
补充说明: PHP默认识别的数据类型是application/x-www.form-urlencoded标准的数据类型 嘻嘻 我是没经过系统学习的 只是查过一些资料而已 理解不深 多谢指教……

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
