Kiran
Kiran

Reputation: 61

How to escape single quotes while printing in php twitter autotweet?

I have functionality to Autotweet text into twitter account. Everything is working fine, but when text contains any single quotes , It post in to twitter as below..

Example: Actual text and expected result : Maneka's 'Beti Bachao' drive goes live

Text displayed in twitter : Maneka�s �Beti Bachao� drive goes live

Please let me know how to escape these single quotes while in php.

Regards, Kiran.

Upvotes: 0

Views: 260

Answers (1)

Suresh Kamrushi
Suresh Kamrushi

Reputation: 16086

Try to use htmlentities() like this:

<?php
$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?>

Upvotes: 1

Related Questions