Welcome Guest, Not a member yet? Register   Sign In
escaping HTML
#1

[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?
#2

[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.ty...tax.nowdoc
#3

[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
#4

[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?
#5

[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.
#6

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

Thanks for the advice! Smile




Theme © iAndrew 2016 - Forum software by © MyBB