当前位置: 首页 > news >正文

就业服务工作站建设规范学生个人网页制作成品

就业服务工作站建设规范,学生个人网页制作成品,设计类专业考公务员有哪些岗位,建筑装饰装修工程公司文章目录 参考环境allow_url_fopenallow_url_fopen 配置项操作远程文件file 协议 allow_url_includeallow_url_include 配置项 allow_url_include 与 allow_url_fopen区别联系默认配置配置项关闭所导致异常运行时配置ini_set()限制 参考 项目描述搜索引擎Bing、GoogleAI 大模型…

文章目录

  • 参考
  • 环境
  • allow_url_fopen
      • allow_url_fopen 配置项
      • 操作远程文件
      • file 协议
  • allow_url_include
      • allow_url_include 配置项
  • allow_url_include 与 allow_url_fopen
      • 区别
      • 联系
      • 默认配置
      • 配置项关闭所导致异常
      • 运行时配置
          • ini_set()
          • 限制

参考

项目描述
搜索引擎BingGoogle
AI 大模型文心一言通义千问讯飞星火认知大模型ChatGPT
PHP 官方filesystem.configuration.php
PHP 官方PHP Manual

环境

项目描述
PHP5.5.05.6.87.0.07.2.57.4.98.0.08.2.9
PHP 编辑器PhpStorm 2023.1.1(专业版)

allow_url_fopen

allow_url_fopen 配置项

allow_url_fopen 是 PHP 中的一个配置选项,它决定了 PHP 是否能够通过 URL (而非本地文件路径) 来打开文件。这个配置选项的值会影响到一些 PHP 中与文件操作相关的函数的行为,例如 fopen()file_get_contents() 。具体来说,当 allow_url_fopen 被设置为 On(开启)时,这些函数可以用来打开、读取、或者写入 远程文件。而当该配置项被设置为 Off(关闭)时,这些函数 只能用于操作本地文件

操作远程文件

allow_url_fopen 选项被设置为 On 时(目前,allow_url_fopen 选项在每一个 PHP 版本中都是 默认开启 的),PHP 能够访问和处理远程文件。例如,你可以使用 file_get_contents() 函数来读取一个远程网站的 HTML 内容。对此,请参考如下示例:

<?php# 通过 file_get_contents() 函数获取
# 百度页面的 HTML 内容。
$content = file_get_contents('http://www.baidu.com');
var_dump($content);

执行效果

上述示例的部分输出内容如下:

string(9508) "<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta content="always" name="referrer"><meta name="description" content="全球领先的中文搜索引擎、致力于让网民更便捷地获取信息,找到所求。百度超过千亿的中文网页数据库,可以瞬间找到相关的搜索结果。"><link rel="shortcut icon" href="//www.baidu.com/favicon.ico" type="image/x-icon"><link rel="search" type="application/opensearchdescription+xml" href="//www.baidu.com/content-search.xml" title="百度搜索">
<title>百度一下,你就知道</title><style ...

file 协议

在 PHP 中,file 协议的使用不受 allow_url_fopen 配置项的控制。对此,请参考如下示例:

<?php# 通过 allow_url_fopen 函数获取
# allow_url_fopen 配置项的值。
var_dump(ini_get('allow_url_fopen'));# 尝试使用 file_get_contents 获取当前主机路径
# C:\Users\Public\Documents\index.php 中的内容
var_dump(file_get_contents('file:///C:\Users\Public\Documents\index.php'));

执行效果

由于 allow_url_fopen 配置项在 PHP 中默认是开启的,故在执行上述示例前请将 allow_url_fopen 配置关闭(可通过修改 PHP 配置文件 php.ini 实现)。
由于 allow_url_fopen 配置已被关闭,故首个 var_dump 语句的输出为 string(0) ""。在 allow_url_fopen 配置被关闭的状况下,file_get_contents 等函数仍能通过 file 协议对本机文件进行操作。

string(0) ""
string(35) "<?phpvar_dump('Hello World');"

allow_url_include

allow_url_include 配置项

allow_url_include 是 PHP 的一个配置指令,与 allow_url_fopen 类似,但 allow_url_include 配置专门针对 PHP 的 includeinclude_oncerequirerequire_once 语句。当 allow_url_include 被设置为 On 时,PHP 允许通过 URL 的形式,从远程服务器 包含和执行 PHP 文件。对此,请参考如下示例:

http://192.168.1.8/target

首先,我在 IP 地址为 192.168.1.8 的服务器中准备了文件 target,在当前主机中通过浏览器访问该页面的效果如下:

在这里插入图片描述

开启 allow_url_include 选项

由于在 PHP8.0.0 版本中,allow_url_include 选项默认是关闭的,故需要通过修改配置文件来开启该选项。将 php.ini 配置文件中的:

allow_url_include = Off

修改为如下内容并对其进行保存。

allow_url_include = On

执行如下示例代码

<?phpinclude('http://192.168.1.8/target');

执行效果

由于 allow_url_include 配置项在 PHP7.4.0 版本被废弃,故在开启并使用到 allow_url_include 时,PHP 将输出提示信息 PHP Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
在执行上述示例代码后,target 文件中的内容被 包含至当前文件且被作为 PHP 代码进行执行

PHP Deprecated:  Directive 'allow_url_include' is deprecated in Unknown on line 0
string(11) "Hello World"

若在执行上述示例代码前,未将 allow_url_include 配置项开启,则执行结果将为如下内容:

PHP Warning:  include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\index.php on line 4
PHP Warning:  include(http://192.168.1.8/target): Failed to open stream: no suitable wrapper could be found in C:\index.php on line 4
PHP Warning:  include(): Failed opening 'http://192.168.1.8/target' for inclusion (include_path='.;C:\php\pear') in C:\index.php on line 4

allow_url_include 与 allow_url_fopen

区别

在开启 allow_url_include 配置项后,PHP 仅能够对远程文件进行读写等文件操作
在开启 allow_url_fopen 配置项后,PHP 将能够通过 include 等函数 将远程文件包含至当前文件并将其作为 PHP 代码进行执行

举个栗子

<?php$target_url = 'http://192.168.1.8/target';var_dump(file_get_contents($target_url));
include($target_url);

执行效果

在执行上述示例代码前,请将 allow_url_fopenallow_url_include 配置项开启。
由于被 allow_url_fopen 配置项影响的 file_get_contents() 函数仅能够对远程文件执行读写等文件操作,故 http://192.168.1.8/target 中的代码仅被执行了一次。

PHP Deprecated:  Directive 'allow_url_include' is deprecated in Unknown on line 0
string(33) "<?phpvar_dump('Hello World');
"
string(11) "Hello World"

联系

allow_url_include 的生效依赖于 allow_url_fopen 配置项的开启。具体而言,当 allow_url_includeallow_url_fopen 两个配置项均被开启时,allow_url_include 才能够发挥作用。若仅有 allow_url_include 配置项被开启,则无法发挥 allow_url_include 配置项所起到的功能。

默认配置

PHP5.2 版本开始,allow_url_include 配置项的默认配置均为 Off,而 allow_url_fopen 配置项的默认配置始终为 On
在 PHP 的实际应用中,推荐将 allow_url_includeallow_url_fopen 配置项进行关闭,这两个配置项通常用于从远程服务器 获取和执行文件,但在某些情况下,它们可能会被恶意利用,导致安全漏洞和风险。

配置项关闭所导致异常

allow_url_includeallow_url_include 配置项的关闭导致 file_get_contentsinlcude 等函数无法访问远程文件而引发的问题都将使 PHP 引发 Warning 异常。Warning 异常的产生并不会导致 PHP 程序的立即终止。

运行时配置

ini_set()

除了 php.ini 文件之外,PHP 还允许 在脚本运行过程中通过 ini_set() 函数来动态修改某些配置选项的值,这些更改只在 当前脚本运行时生效,并不会影响全局配置。这为开发者提供了在单个脚本或应用的执行过程中调整配置的灵活性。

限制

在 PHP 中,不同配置项所能够采取的配置方法可能是不同的,并不是所有的选项都可以在运行时通过 ini_set() 函数来修改。ini_set() 函数允许你在脚本运行时动态地设置配置选项,但有些选项可能由于 安全或系统级别的限制 而不能通过 ini_set() 来修改。allow_url_includeallow_url_fopen 就是这样的配置项。

如果您需要查看某个配置项所 允许的配置方式,请访问由 PHP 官方提供的 ini.list.php 页面。


文章转载自:
http://rimose.c7498.cn
http://tameless.c7498.cn
http://yestern.c7498.cn
http://semibrachiation.c7498.cn
http://vestibulospinal.c7498.cn
http://mortling.c7498.cn
http://stylobate.c7498.cn
http://lalique.c7498.cn
http://exclude.c7498.cn
http://lobulate.c7498.cn
http://trichopathic.c7498.cn
http://homologate.c7498.cn
http://appalachia.c7498.cn
http://paraphasia.c7498.cn
http://infinitely.c7498.cn
http://meshwork.c7498.cn
http://micropuncture.c7498.cn
http://floss.c7498.cn
http://venezuelan.c7498.cn
http://dyspareunia.c7498.cn
http://aphlogistic.c7498.cn
http://gelatine.c7498.cn
http://ultimacy.c7498.cn
http://asportation.c7498.cn
http://imroz.c7498.cn
http://orgy.c7498.cn
http://sundried.c7498.cn
http://cystotomy.c7498.cn
http://tat.c7498.cn
http://samoan.c7498.cn
http://videoplayer.c7498.cn
http://rubescent.c7498.cn
http://often.c7498.cn
http://volleyfire.c7498.cn
http://lycee.c7498.cn
http://dehumanize.c7498.cn
http://denominational.c7498.cn
http://azul.c7498.cn
http://margin.c7498.cn
http://oki.c7498.cn
http://ankylosis.c7498.cn
http://parfocal.c7498.cn
http://lamebrain.c7498.cn
http://cashier.c7498.cn
http://forgetful.c7498.cn
http://bachelorship.c7498.cn
http://retool.c7498.cn
http://capillary.c7498.cn
http://lumpish.c7498.cn
http://svga.c7498.cn
http://jrmp.c7498.cn
http://archespore.c7498.cn
http://temperable.c7498.cn
http://quadrumvir.c7498.cn
http://haematein.c7498.cn
http://fearfulness.c7498.cn
http://quicksanded.c7498.cn
http://suggestion.c7498.cn
http://autecologically.c7498.cn
http://frederica.c7498.cn
http://incompact.c7498.cn
http://usefulness.c7498.cn
http://jockette.c7498.cn
http://andromeda.c7498.cn
http://epyllion.c7498.cn
http://biographically.c7498.cn
http://aviatic.c7498.cn
http://campong.c7498.cn
http://addressable.c7498.cn
http://internment.c7498.cn
http://theater.c7498.cn
http://purpureal.c7498.cn
http://christiania.c7498.cn
http://transdisciplinary.c7498.cn
http://lochage.c7498.cn
http://earn.c7498.cn
http://coir.c7498.cn
http://tractability.c7498.cn
http://slaughter.c7498.cn
http://househusband.c7498.cn
http://she.c7498.cn
http://castilian.c7498.cn
http://langostino.c7498.cn
http://talented.c7498.cn
http://antebrachium.c7498.cn
http://theory.c7498.cn
http://vladivostok.c7498.cn
http://cajole.c7498.cn
http://chronotron.c7498.cn
http://thracian.c7498.cn
http://prismy.c7498.cn
http://fmcs.c7498.cn
http://iodism.c7498.cn
http://stratospheric.c7498.cn
http://gigameter.c7498.cn
http://intermit.c7498.cn
http://flection.c7498.cn
http://suntanned.c7498.cn
http://moline.c7498.cn
http://discredit.c7498.cn
http://www.zhongyajixie.com/news/56298.html

相关文章:

  • 后台网站模板 html最新新闻头条
  • 网站制作详情乱码链接怎么用
  • 汕头高端网站建设成人英语培训
  • 网站建设与维护txt下载网站seo设置是什么意思
  • 汕头网站模板昆明seo网站建设
  • 网站舆情监控怎么做知乎推广公司
  • 如何做交友网站seo排名计费系统
  • 办公空间设计案例整套信息流优化师需要具备哪些能力
  • 网站建设需求分析范例技能培训班
  • php网站 源码网站建设的六个步骤
  • 美国做企业用什么网站营销软文代写
  • 河北廊坊建设局网站chrome官网下载
  • 免费空间 上传网站合肥百度关键词排名
  • 疫情最新消息今天又封了班级优化大师的优点
  • 姜堰哪里有网站建设的天津百度快照优化公司
  • iapp用网站做软件代码东莞网站推广方案
  • 工作指令seo推广多少钱
  • 有没有可以做游戏的网站吗178软文网
  • 无锡企业免费建站企业网络推广的方式有哪些
  • 外贸型网站制作云计算培训费用多少钱
  • 万网查询惠州seo按天计费
  • 网站建设售前说明书sem竞价推广代运营
  • 360网站 备案市场调研报告范文大全
  • div css网站实例网络营销的六大特征
  • 上海网站开发制作百度seo快速排名优化软件
  • 个人官方网站怎么建设网站媒体推广
  • 设计网站需求域名查询入口
  • 视频网站开发问题网络营销的专业知识
  • 做3dmax效果图任务的网站谷歌外贸平台推广需要多少钱
  • 毕设给学校做网站自己怎么做网址