如何使用HTTPS包含文件-PHP [英] How to include files with HTTPS - PHP
问题描述
我进行了表单处理,并将代码分解为不同的文件,以保持整洁有序.
I made a form process and broke the code up into different files to stay clean and organized.
现在,我正在为https安全设置表单.
Now I am setting up the form for https security.
是否也必须将我拉入页面的所有文件都称为https? 在这种情况下,我不能再使用include();.因为它不再允许相对路径了?
Do all the files I pull into my page have to be called as https as well? In which case I can no longer use include(); as it no longer allows relative paths?
使用file_get_contents();的解决方案吗?还是仅需要将(母版)页面本身称为https?
Is the solution to use file_get_contents();? Or does only the (master) page itself need to be called as https?
推荐答案
听起来好像您在混淆术语. HTTPS是用于使用SSL或TLS加密从服务器请求页面的协议.这与您处理请求的方式不同.
It sounds like you are confusing terminology. HTTPS is the protocol used to request a page from the server using SSL or TLS encryption. That is separate from how you serve the request.
在您的PHP源代码中包括已处理的服务器端.所有包括在内的操作都将在PHP将页面移交给Web服务器以通过TLS链接返回之前完成.
In your PHP source includes are processed server-side. All of the includes will be done before PHP hands the page off to your web server to be returned over the TLS link.
file.php:
<?php
include 'fileA.php';
include 'fileB.php';
?>
在上面的示例中,用户代理(浏览器)从没有看到fileA.php或fileB.php.页面请求作为单个文档返回.您可以通过 https://my-server.com/file.php 进行请求,其中这就是您所需要的.
In the example above, the user agent (browser) never sees fileA.php or fileB.php. The page request is returned as a single document. You might request it via https://my-server.com/file.php, in which case that is all you need.
这篇关于如何使用HTTPS包含文件-PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!