Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在哪里存储html页面更好?_Php_Codeigniter - Fatal编程技术网

Php 在哪里存储html页面更好?

Php 在哪里存储html页面更好?,php,codeigniter,Php,Codeigniter,在数据库中还是在文件本身中存储html页面更好 如果我有很多文件: user/login.php user/register.php user/somethingElse.php articles/index.php articles/view.php articles/somethingElse.php 所有的代码都存储在那里,或者将这些页面作为html存储在数据库中,然后仅将其呈现为一个文件内容。php?您可以将html代码存储在php文件中,或者使用html文件让php获取这些文件。我可以

在数据库中还是在文件本身中存储html页面更好

如果我有很多文件:

user/login.php

user/register.php

user/somethingElse.php

articles/index.php

articles/view.php

articles/somethingElse.php


所有的代码都存储在那里,或者将这些页面作为html存储在数据库中,然后仅将其呈现为一个文件内容。php?

您可以将html代码存储在php文件中,或者使用html文件让php获取这些文件。

我可以说,将html存储到文件中要比DB好得多,因为

1)For retrieving data also you need to perform DB operations as well,so it may stuck DB somewhere when load is become a 'real load' to operate DB
2)A DB can crash but a file cont much when compared to DB
3)If you want to change the HTML you need to perform agian update operation for that which makes big issue for an developer to work 
4)And also in DB you need to store HTML tags,other things using 'htmlentities' which causes conflict  

我喜欢这样做的方式是在我的root:/index.php-file中保留尽可能多的HTML,然后根据用户希望看到的页面加载所需的文件

F.x.用户想要看到我发送给index.php的文章吗?page=articles,加载页面布局并包括(“articles/index.php”);这还可以让您使用htaccess使url的外观更好


但一般来说,除非是用户提交的内容,否则不要在SQL中保留HTML代码。

您需要提供更多详细信息。如何更好地定义
?这是一个主观的术语,我指的是一种更灵活的方式,通常即使是大型CMS也只在数据库中存储内容和设置,而不存储代码本身。代码驻留在文件系统中。我有3个文件:header.php、content.php、footer.php,我想如果我将所有的html从数据库呈现到content.php,这将是一个好主意还是一个坏主意?是的,看起来你是对的