<code>发起http请求后 network会显示各类加载的资源,php有什么办法获取某一type的name size等信息吗?</code>
用curl HEAD协议可行吗?
回复内容:
<code>发起http请求后 network会显示各类加载的资源,php有什么办法获取某一type的name size等信息吗?</code>
用curl HEAD协议可行吗?
描述不是很清楚,你是希望:
服务器端主动去发起一个请求去拿信息? => 可行
还是等客户端网页加载完成之后上报服务器浏览器获取到的信息? => 不可行
对于1,curl是可以的一个方案,不一定需要使用HEAD方式,GET,POST,DELETE,PUT方式你都可以拿到返回的HTTP头,只要你加上CURLOPT_HEADER参数
<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_URL, "http://sf.gg/"); $response = curl_exec($ch); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $headerText = substr($response, 0, $headerSize); $bodyText = substr($response, $headerSize); echo $headerText; //即获取的http头,你会看到还有一次302跳转
可以的,
<code>$info = curl_getinfo($ch);</code>
打印出$info后就有你需要的
$SERVER['PHPSELF'] #当前正在执行脚本的文件名,与 document root相关。
$_SERVER['argv'] #传递给该脚本的参数。
$_SERVER['argc'] #包含传递给程序的命令行参数的个数(如果运行在命令行模式)。
$SERVER['GATEWAYINTERFACE'] #服务器使用的 CGI 规范的版本。例如,“CGI/1.1”。
$SERVER['SERVERNAME'] #当前运行脚本所在服务器主机的名称。
$SERVER['SERVERSOFTWARE'] #服务器标识的字串,在响应请求时的头部中给出。
$SERVER['SERVERPROTOCOL'] #请求页面时通信协议的名称和版本。例如,“HTTP/1.0”。
$SERVER['REQUESTMETHOD'] #访问页面时的请求方法。例如:“GET”、“HEAD”,“POST”,“PUT”。
$SERVER['QUERYSTRING'] #查询(query)的字符串。
$SERVER['DOCUMENTROOT'] #当前运行脚本所在的文档根目录。在服务器配置文件中定义。
$SERVER['HTTPACCEPT'] #当前请求的 Accept: 头部的内容。
$SERVER['HTTPACCEPT_CHARSET'] #当前请求的 Accept-Charset: 头部的内容。例如:“iso-8859-1,*,utf-8”。
$SERVER['HTTPACCEPT_ENCODING'] #当前请求的 Accept-Encoding: 头部的内容。例如:“gzip”。
$SERVER['HTTPACCEPT_LANGUAGE']#当前请求的 Accept-Language: 头部的内容。例如:“en”。
$SERVER['HTTPCONNECTION'] #当前请求的 Connection: 头部的内容。例如:“Keep-Alive”。
$SERVER['HTTPHOST'] #当前请求的 Host: 头部的内容。
$SERVER['HTTPREFERER'] #链接到当前页面的前一页面的 URL 地址。
$SERVER['HTTPUSERAGENT'] #当前请求的 UserAgent: 头部的内容。
$_SERVER['HTTPS'] — 如果通过https访问,则被设为一个非空的值(on),否则返回off
$SERVER['REMOTEADDR'] #正在浏览当前页面用户的 IP 地址。
$SERVER['REMOTEHOST'] #正在浏览当前页面用户的主机名。
$SERVER['REMOTEPORT'] #用户连接到服务器时所使用的端口。
$SERVER['SCRIPTFILENAME'] #当前执行脚本的绝对路径名。
$SERVER['SERVERADMIN'] #管理员信息
$SERVER['SERVERPORT'] #服务器所使用的端口
$SERVER['SERVERSIGNATURE'] #包含服务器版本和虚拟主机名的字符串。
$SERVER['PATHTRANSLATED'] #当前脚本所在文件系统(不是文档根目录)的基本路径。
$SERVER['SCRIPTNAME'] #包含当前脚本的路径。这在页面需要指向自己时非常有用。
$SERVER['REQUESTURI'] #访问此页面所需的 URI。例如,“/index.html”。
$SERVER['PHPAUTH_USER'] #当 PHP 运行在 Apache 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的用户名。
$SERVER['PHPAUTH_PW'] #当 PHP 运行在 Apache 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的密码。
$SERVER['AUTHTYPE'] #当 PHP 运行在 Apache 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是认证的类型。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

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.


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

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

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

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.