编写控制面板脚本来修改php文件

时间:2022-06-14 05:59:13

I have a PHP file that contains a lot of "if" and "else" statements that determine what content a user sees (let's called this a block). I constantly have to modify this file (let's call it output.php), but it's a bit cumbersome with just a text editor.

我有一个PHP文件,其中包含许多“if”和“else”语句,用于确定用户看到的内容(让我们将其称为块)。我经常不得不修改这个文件(我们称之为output.php),但只是文本编辑器有点麻烦。

What I want to do is use a simple web interface to modify output.php. I was thinking of using a PHP script that would break up output.php into chunks with links to forms where can I can modify each chunk. Here's an example:

我想要做的是使用一个简单的Web界面来修改output.php。我正在考虑使用一个PHP脚本,它会将output.php拆分为包含表单链接的块,我可以在其中修改每个块。这是一个例子:

output.php format:

<block A>
   title = ...
   description = ...
<block B>
   title = ...
   description = ...
...

script that modifies output.php

修改output.php的脚本

<Link to a form that I can use to edit block A, and save>
<Link to a form that I can use to edit block B, and save>
...
<buttons that let me add new blocks, etc.>

It's just a simple interface that lets me edit output.php. I was wondering if there's an easy method to do this in PHP?

它只是一个简单的界面,让我编辑output.php。我想知道在PHP中是否有一种简单的方法可以做到这一点?

Also, would anyone recommend that I start using databases to manage this data? It started off from just two blocks of data with an if/else statement, but now there's going to be up to a hundred blocks.

另外,有人会建议我开始使用数据库来管理这些数据吗?它仅使用if / else语句从两个数据块开始,但现在最多会有一百个块。

2 个解决方案

#1


Why not just put each "block" in its own file and use include/require?

为什么不把每个“块”放在自己的文件中并使用include / require?

Although, yeah, if this is basically a content management system, you should probably use a database. Or, use a content management system that's already been built, like WordPress.

虽然,是的,如果这基本上是一个内容管理系统,你应该使用一个数据库。或者,使用已经构建的内容管理系统,如WordPress。

#2


Start using database and relations, create one-to-many relation between user table (users) and access table (allowed parts).

开始使用数据库和关系,在用户表(用户)和访问表(允许的部分)之间创建一对多关系。

#1


Why not just put each "block" in its own file and use include/require?

为什么不把每个“块”放在自己的文件中并使用include / require?

Although, yeah, if this is basically a content management system, you should probably use a database. Or, use a content management system that's already been built, like WordPress.

虽然,是的,如果这基本上是一个内容管理系统,你应该使用一个数据库。或者,使用已经构建的内容管理系统,如WordPress。

#2


Start using database and relations, create one-to-many relation between user table (users) and access table (allowed parts).

开始使用数据库和关系,在用户表(用户)和访问表(允许的部分)之间创建一对多关系。