3
It is possible to save an HTML file in a column BLOB
inside the database and then display as part of the page in PHP?
Why do this: it’s more of a learning experiment to compare whether it looks better than a include
on the page.
3
It is possible to save an HTML file in a column BLOB
inside the database and then display as part of the page in PHP?
Why do this: it’s more of a learning experiment to compare whether it looks better than a include
on the page.
4
The file itself is not possible, after all file is a concept of the operating system file system, but a text that is an HTML is entirely possible. It doesn’t even have to be a BLOB
. It may be that kind of column, but it may be a TEXT
or VARCHAR
and even a CHAR
although probably quite inadequate. You don’t need to have a file to generate the content, what will be delivered needs to be a text recognized as HTML, that’s all.
Of course, it is the function of your application to properly deliver to the HTTP server so that this HTML is sent to the client when you have a request. Your application can take this HTML from anywhere, can compose multiple parts, you can do whatever you want. If you can compose coherently is a very powerful tool to give flexibility in the result.
You must avoid abuse, you must take care of security, it may not be the most performance, it may not be the most suitable for what you need, but these are other issues.
Now I can say it doesn’t get any better than include
, make use of a database only if necessary.
I would save to type varbinary and recover byte[] to then convert to string.
Browser other questions tagged php html sql database blob
You are not signed in. Login or sign up in order to post.
Anything with
echo
is part of HTML. So, if you pull from the bank a record with HTML code and make aecho
, will be rendered as HTML.– Sam
So in practice would be the same thing? or slower?
– João Victor
Slower because you have to apply to the bank before. In my view this is not a good practice, since there is include for this function.
– Sam
Yes it’s totally possible, actually it’s like CMS like Wordpress work.
– Kaoe Coito
Yes, there are many ways to do that.
– Matheus Miranda