Jump to content

How do I concatenate htmlspecialchars? :/


Go to solution Solved by Barand,

Recommended Posts

I need to put this inside of a p tag so I can change some properties but everything I've tried doesn't work and just shows nothing.

 

I've tried this:

printf('<p style="text-align: left; width: 500px;">', htmlspecialchars($fetch['shout'], ENT_QUOTES, 'UTF-8'), '</p>');

This is what I need to be wrapped in p tags:

htmlspecialchars($fetch['shout'], ENT_QUOTES, 'UTF-8');

EDIT: I've noticed the code below works but when I style it inside of the tag the text won't show, should I include a CSS file on the PHP file?

echo "<p>".htmlspecialchars($fetch['shout'])."</p>\n";

EDIT: I just needed to create the CSS for the p tags in the index and it worked perfectly fine.  :sweat:

 

Sorry for the pointless thread.

Edited by Alanay
Link to comment
https://forums.phpfreaks.com/topic/293165-how-do-i-concatenate-htmlspecialchars/
Share on other sites

  • Solution

If you are going to use printf(), use it correctly with %s placeholder for the string argument.

 

printf('<p style="text-align: left; width: 500px;">%s</p>', htmlspecialchars($fetch['shout'], ENT_QUOTES, 'UTF-8'));

If you are going to use printf(), use it correctly with %s placeholder for the string argument.

 

printf('<p style="text-align: left; width: 500px;">%s</p>', htmlspecialchars($fetch['shout'], ENT_QUOTES, 'UTF-8'));

 

Thank you, works perfectly.

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.