CodeIgniter Forums
escaping HTML - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: escaping HTML (/thread-17018.html)



escaping HTML - El Forum - 03-23-2009

[eluser]Fenix[/eluser]
I remember seeing something in a CI plugin library before like
Code:
$var = <<[HTML] &lt;html stuff here&gt; [HTML]>>

I want to have a variable hold html and escaping all of the html entities would be tedious.

Anybody know the exact syntax for this?


escaping HTML - El Forum - 03-23-2009

[eluser]Fenix[/eluser]
I managed to figure it out on my own. It is called Heredoc or Nowdoc syntax. More information can be found in the PHP manual here:

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc


escaping HTML - El Forum - 03-23-2009

[eluser]TheFuzzy0ne[/eluser]
Why not just load a view into the variable? Then you'd have the added bonus of having syntax highlighting, and of course, keeping the V separate from the C. Smile


escaping HTML - El Forum - 03-23-2009

[eluser]Fenix[/eluser]
I've thought about this but I assumed it would affect the performance to load multiple views. You and your 1732 posts would probably know better Tongue

So how much does loading multiple views affect performance?


escaping HTML - El Forum - 03-23-2009

[eluser]TheFuzzy0ne[/eluser]
[quote author="Fenix" date="1237859891"]I've thought about this but I assumed it would affect the performance to load multiple views. You and your 1732 posts would probably know better Tongue[/quote]

Not at all. I just talk too much...

[quote author="Fenix" date="1237859891"]So how much does loading multiple views affect performance?[/quote]

How long is a piece of string?

It depends on hard drive specs, server load, fragmentation and numerous other factors. However, I'd imagine that any hit in performance would be minimal.

My main template loads 5 other views, and my pages still generally load in under 0.25 seconds, even on my run down server, and that includes database queries. Think about it this way: CodeIgniter loads about 20 files, not including any libraries or anything else you load (20 is a guess, it could be more, it could be less), a few more file loads make hardly any difference. If it concerns you that much, you might want to look into caching.


escaping HTML - El Forum - 03-23-2009

[eluser]Fenix[/eluser]
Good points. And yes, I've considered caching.

Thanks for the advice! Smile