This is more a question of curiosity.

这更像是一个好奇的问题。

So I was reading a chapter from (Sitepoint's latest PHP/MySQL book), in which the author mentioned using the extension ".html.php" to indicate files that has both HTML and PHP. I tried it out, and discovered this:

所以我正在阅读(Sitepoint最新的PHP / MySQL书籍)中的一章,其中作者提到使用扩展名“.html.php”来表示同时包含HTML和PHP的文件。我试了一下,发现了这个:

If I have a file "fileA.html.php", and somewhere in "fileB.html" I have a link thusly:

如果我有一个文件“fileA.html.php”,并且在“fileB.html”的某处,我有一个链接:

<a href="fileA.html">Text text</a>

I'm able to link directly to fileA.html.php, correctly parsed, even though logic, and the book, tells me that I should have written href="fileA.html.php".

我能够直接链接到fileA.html.php,正确解析,即使逻辑和本书告诉我,我应该写href =“fileA.html.php”。

Anyone have any idea what PHP function does this, or if it's just standard PHP behavior? (Not that I'm complaining, it's just something my client noted and thought was cool.)

任何人都知道PHP函数是做什么的,或者它只是标准的PHP行为? (不是我抱怨,这只是我的客户注意到并认为很酷的东西。)

5 个解决方案

#1


You'd have to have your server configured to do that. If you're using Apache there are numerous ways to accomplish that with htaccess rewrite rules or other processors.

您必须配置您的服务器来执行此操作。如果你正在使用Apache,有许多方法可以通过htaccess重写规则或其他处理器来实现。

But if you're going to go to those lengths, why require the html at all? I'd say either serve the file with the appropriate extension type (in that case just .php) or make it extensionless or extension-optional. The only reason to do it at all is to make it easier on your users. There's no advantage for changing the extension otherwise.

但是,如果你要去那么长,为什么要求html呢?我要么说要么使用适当的扩展类型(在这种情况下只是.php)提供文件,要么使其无扩展或扩展可选。完全这样做的唯一原因是让用户更容易。否则,更改扩展名没有任何优势。

更多相关文章

  1. include一个php文件,经常会失败,请问需要注意些什么?
  2. php清理当前目录下的指定文件和空目录(源码),建议服务器端执行
  3. 如何从其他文件调用数组
  4. 用于上传多个文件的PHP代码
  5. php中如何获取文件的正确路径
  6. 入门: 如何在xampp中运行php文件 (WINDOWS)
  7. 自动同步vps服务器或本地文件的数据到百度网盘
  8. PHP文件操作 - 替换某行,插入某行,删除某行,获取行号
  9. php读取目录及子目录下所有文件名的方法

随机推荐

  1. Linux学习之linux的find命令如何使用?
  2. python数据类型的强制转换
  3. 动画:面试必刷之对称的二叉树
  4. 字符串处理函数
  5. 就说一件事!
  6. Spring Cloud分布式微服务实战(养成应对复
  7. 自学系列 | 就谈自学方法!
  8. 动画:「变量提升」引发的一场"血"案 !
  9. 动画:面试必刷之二叉树的镜像
  10. 标识符的认识