如何获取请求服务器的IP
我A服务器上有a.php,然后用B服务器上的b.php传参给a.php,如何让a.php知道B的IP地址,谢谢
回复讨论(解决方案)
$_SERVER['REMOTE_ADDR'] 获取请求方的IP
$_SERVER['REMOTE_ADDR'] 获取请求方的IP
试过了 这个只能取当前打开浏览器的电脑的IP,我的请求是程序在后台发的
你如何请求 b.php 的?
你如何请求 b.php 的?
file_get_contents
gethostbyname 得到指定的Internet主机名对应的IP地址
例:
echo gethostbyname('bbs.csdn.net'); //117.79.157.198
gethostbyname 得到指定的Internet主机名对应的IP地址
例:
echo gethostbyname('bbs.csdn.net'); //117.79.157.198
我想只让指定的主机IP访问,你这样只能获得某一台IP,但我不知道对方是哪台服务器在提交申请
我A服务器上有a.php,然后用B服务器上的b.php传参给a.php,如何让a.php知道B的IP地址,谢谢
$_SERVER[SERVER_ADDR]
我A服务器上有a.php,然后用B服务器上的b.php传参给a.php,如何让a.php知道B的IP地址,谢谢
$_SERVER[SERVER_ADDR]
这个取到的还是B服务器的IP啊,我要取A服务
#0: 如何让a.php知道B的IP地址
#8: 还是B服务器的IP啊,我要取A服务
你先想清楚了再提问!
#0: 如何让a.php知道B的IP地址
#8: 还是B服务器的IP啊,我要取A服务
你先想清楚了再提问!
不好意思 隔了三天我搞错了 ,是A要取B的地址 = = $_SERVER[SERVER_ADDR]以上方法要建立在B服务器把IP传给A的情况下才成功,但是对方能传假的值
那用 gethostbyname 取得的 ip 为什么就不行呢?
那用 gethostbyname 取得的 ip 为什么就不行呢?
我是一个充值平台,我为了防止合作商私下接入所以要规定白名单 只有白名单里的IP请求才有效,这样。。
gethostbyname 的参数是域名,返回的是相应的主机的ip
如果连这个都不可信的话,那我就无语了
gethostbyname 的参数是域名,返回的是相应的主机的ip
如果连这个都不可信的话,那我就无语了
这个是可信的,不用这个的原因是我知道某IP肯定是我们的合作商,但是要是第三方介入的话 我既不知道他的域名也不知道他的IP 就没法判断了
你如何请求 b.php 的?
file_get_contents 我既不知道他的域名也不知道他的IP
那你怎么 file_get_contents ?
你如何请求 b.php 的?
file_get_contents 我既不知道他的域名也不知道他的IP
那你怎么 file_get_contents ?
这句是写在B服务器上的 ,这台服务器不是我的,所以要是靠他传值的话 不能确定真假,要从我自己的服务器A获取B的请求地址才行
亲,file_get_contents可以在A机器上获取B的地址的,这个函数还可以用来判断一个域名是不是真的存在
上面说错了,是gethostbyname函数
上面说错了,是gethostbyname函数 这函数前提是你要知道对方的域名呀 ,现在我不知道请求方的域名
那一般就是看$_SERVER变量的REMOTE_ADDR,HTTP_X_FORWARDED_FOR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR这些参数了
那一般就是看$_SERVER变量的REMOTE_ADDR,HTTP_X_FORWARDED_FOR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR这些参数了 所以说使用哪个。。。我不是很熟
继续求。。。。。。
好的 。。。找到原因了 谢谢楼上各位

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics











PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
