如何使用 HTTPS 包含文件 - PHP

发布于 2024-08-05 01:08:48 字数 206 浏览 1 评论 0 原文

我制定了一个表单流程,并将代码分解为不同的文件,以保持整洁和组织。

现在我正在设置 https 安全性的表单。

我拉入页面的所有文件是否也必须以 https 形式调用? 在这种情况下我不能再使用 include();因为它不再允许相对路径?

解决方案是使用 file_get_contents(); 吗?或者只有(主)页面本身需要被称为 https?

I made a form process and broke the code up into different files to stay clean and organized.

Now I am setting up the form for https security.

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?

Is the solution to use file_get_contents();? Or does only the (master) page itself need to be called as https?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

も星光 2024-08-12 01:08:48

听起来你对术语感到困惑。 HTTPS 是用于使用 SSL 或 TLS 加密从服务器请求页面的协议。这与您处理请求的方式是分开的。

在您的 PHP 源代码中,包含内容是在服务器端处理的。所有包含内容都将在 PHP 将页面交给您的 Web 服务器以通过 TLS 链接返回之前完成。

file.php:

<?php
include 'fileA.php';
include 'fileB.php';
?>

在上面的示例中,用户代理(浏览器)永远不会看到 fileA.php 或 fileB.php。页面请求作为单个文档返回。您可以通过 https://my-server.com/file.php 请求它,其中这就是您所需要的。

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.

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';
?>

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.

迷爱 2024-08-12 01:08:48

如果文件位于同一服务器上,则无需更改任何内容。

包括(“文件.php”);

会工作得很好。

另外,如果您要包含来自其他 https 服务器的文件,只要您正确设置了 tls 库,https 就不是问题

include("https://anotherserver.com/file.php");

如果其他服务器提供 PHP 服务并且不执行它,则可以工作。

IF the files are on the same server you don't need to change anything.

include("file.php");

Will work just fine.

Also if you were to include a file from a nother https server, as long as you have the tls libraries setup properly, https isn't a problem

include("https://anotherserver.com/file.php");

would work provided the other server serves the PHP and does not execute it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文