可以用php修改文件名吗?

发布于 2024-11-25 06:47:12 字数 244 浏览 4 评论 0原文

所以这就是我们的想法。 您可以使用 php 更改/重命名文件的名称吗?我想这样

您有几个页面都是相同的“模板”,只是内容和名称不同,例如您有一些名为“portfolio-item-1.php”的文件 如果有人点击“下一个”链接,它会转到“portfolio-item-2.php”,因此同一文件刚刚重命名,并且使用 ID 的不同内容?

这可能令人困惑,但是......

我知道你可以做这个数据库,但是,有没有没有数据库的方法?

So here's the idea.
Can you change/rename the name of the file using php.I was thinkig like this

you have couple of pages all same "template" just different content and name for example you have some file named "portfolio-item-1.php"
and if someone click "next" link it goes to "portfolio-item-2.php" so the same file just renamed and different content using ID's ?

It's maybe confusing but .. .

I know you can do this Database but, is there a way without database?

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

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

发布评论

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

评论(2

等待圉鍢 2024-12-02 06:47:12

你真的不想这样做!从你所说的你想要做的事情来看, GET / POST 会好得多。

例如链接到 portfolio-item.php?page=2
您可以通过以下方式获取页码:

$page = isset($_GET['page']) ? $_GET['page'] : 1;

这会将 page 设置为 URL 中的 ID(如果存在),否则将使用 1 作为页码。

You really don't want to do that! From what you say you're trying to do, a GET / POST would be far better.

E.g. link to portfolio-item.php?page=2
You can get the page number by:

$page = isset($_GET['page']) ? $_GET['page'] : 1;

This will set page to the ID in the URL if it's there, otherwise it'll use 1 as the page number.

此岸叶落 2024-12-02 06:47:12

psynnott 拥有您想要实施的最佳方法。
您可以使用命名空间而不是整数,但这同样适用。

psynnott has the best method you would want to implement.
you can use a namespace instead of an integer but the same applies.

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