网页显示的设置在哪里保存? (php/xml/json/ini)
我有一个小模板类,它将所有设置保存在 php 类中。
这些设置是:每个页面的 css 样式、js 脚本、元标记和标题。 (例如,在index.php 上我需要一些js 脚本,但对于contacts.php - 其他js 文件)。
编辑此配置数据不是很舒服,因为它是类的私有属性,并且在编辑时程序员可能会在 php 代码中犯错误)。
将这些配置数据保存在外部文件中是个好主意吗? xml/json/ini ? 这会让网站渲染速度变慢吗?
I have a little Templating class, that keeps all settings inside the php class.
These settings are: css styles, js scripts, meta tags and titles for every page. (For example on index.php I need some js-scripts, but for contacts.php - other js-files).
It's not very comfortable to edit this configuration data, because it is in private properties of a class, and while editing programmer can make mistakes in php code).
Is it a good idea to keep this configuration data in external files? Xml/json/ini ?
Will this get site rendering much slower?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
using.ini 文件是 PHP 中的一个很棒的功能:
根据您的评论 - 加载速度并不快。但您始终可以将 .ini 文件缓存在内存中:
现在这是完美的解决方案。 :)
using.ini files is great feature in PHP:
According to your comment - loading it's not that fast. But you can always cache .ini files in memory:
Now it's perfect solution. :)
是的,这是一个好主意,通常这些被称为配置文件。
选择适合您的需求和偏好的内容。
没有渲染与之无关,渲染代码不会改变。
Yes that's a good idea, normally those are called configuration files.
Choose whatever suits your needs and preference.
No rendering is not related to it, the rendering code will not be changed.