Jump to content

Recommended Posts

Hello friends!  I have to be missing something, and I hope you can point it out!

$output = htmlspecialchars("isn't it nice & clean");
echo $output;

outputs:

isn't it nice & clean

 

I inspect element in chrome and I see:

isn't it nice & clean

 

Shouldn't it be:

isn't it nice & clean

 

??

 

Confused!

 

Thanks

Nick

Link to comment
https://forums.phpfreaks.com/topic/295098-htmlspecialchars-question/
Share on other sites

But & is, and it wasn't showing in inspect elements.  I finally found a google search hit that stated to "view source"  and there was the &.

 

I added ENT_QUOTES so the code looks like:

$output = htmlspecialchars("isn't it nice & clean", ENT_QUOTES);
echo $output;

 

and now I view source instead of inspect element and I get:

isn't it nice & clean

 

I had seen many posts to "htmlspecialchars not working" and they all said if you inspect element you will see.  Yet inspect element didn't work.  Did something change?

 

Either way, foolish of me to trust inspect element.

 

Thanks for the reply!

 

Nick

Inspect element has nothing to do with PHP. It is a feature of the web browser. To see the actual output from your PHP script you need to right click > view source

 

Inspect element is most likely prettifying the HTML. It is not a sign htmlentities is not working.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.