0

I have an if statement that looks like this:

if($benchmark_one_name2 === "Russell 1000 Index"){
    $benchmark_one_name2 = "<span class='first'>Russell 1000 Index</span>";
    var_dump("this if statement is true");
}
var_dump($benchmark_one_name2);die;

Then I var_dump the value of $benchmark_one_name2 right after to see if it has been set to "<span class='first'>Russell 1000 Index</span>", but instead i get back this when I check the page:

string(25) "this if statement is true" string(45) "Russell 1000 Index" 

I think it might have something to do with the HTML inside the string, but can't seem to find anything indicating that.

p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
Andrew Font
  • 1,245
  • 3
  • 19
  • 38
  • 2
    Check the source code of your page. `Russell 1000 Index` is not 45 characters. The `` is being rendered as HTML. – gen_Eric Mar 06 '14 at 20:38
  • 5
    Your browser is rendering html tags. Thats why the length is 45 yet the text is only 18 chars – Mike B Mar 06 '14 at 20:38

1 Answers1

4

It's outputting the value as you expect, but your browser is parsing the output as HTML. If you inspect the document you will see:

string(25) "this if statement is true"
string(45) "<span class="first">Russell 1000 Index</span>"
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331