पीएचपी html_entity_decode () फ़ंक्शन
उदाहरण
HTML निकायों को वर्णों में बदलें:
<?php
$str = '<a href="https://www.w3schools.com">w3schools.com</a>';
echo html_entity_decode($str);
?>
उपरोक्त कोड का HTML आउटपुट होगा (स्रोत देखें):
<a href="https://www.w3schools.com">w3schools.com</a>
उपरोक्त कोड का ब्राउज़र आउटपुट होगा:
परिभाषा और उपयोग
html_entity_decode() फ़ंक्शन HTML निकायों को वर्णों में परिवर्तित करता है।
html_entity_decode() फ़ंक्शन htmlentities() के विपरीत है ।
वाक्य - विन्यास
html_entity_decode(string,flags,character-set)
पैरामीटर मान
Parameter | Description |
---|---|
string | Required. Specifies the string to decode |
flags | Optional. Specifies how to handle quotes and which document type to use. The available quote styles are:
Additional flags for specifying the used doctype:
|
character-set | Optional. A string that specifies which character-set to use. Allowed values are:
Note: Unrecognized character-sets will be ignored and replaced by ISO-8859-1 in versions prior to PHP 5.4. As of PHP 5.4, it will be ignored an replaced by UTF-8. |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | परिवर्तित स्ट्रिंग लौटाता है |
---|---|
पीएचपी संस्करण: | 4.3.0+ |
चेंजलॉग: | PHP 5.6 - कैरेक्टर-सेट
पैरामीटर के लिए डिफ़ॉल्ट मान को डिफ़ॉल्ट वर्णसेट (कॉन्फ़िगरेशन में) के मान में बदल दिया। PHP 5.4 - कैरेक्टर-सेट पैरामीटर के लिए डिफ़ॉल्ट मान को UTF-8 में बदल दिया। PHP 5.4 - ENT_HTML401, ENT_HTML5, ENT_XML1 और ENT_XHTML जोड़ा गया। PHP 5.0 - बहु-बाइट एन्कोडिंग के लिए जोड़ा गया समर्थन |
और ज्यादा उदाहरण
उदाहरण
कुछ HTML निकायों को वर्णों में बदलें:
<?php
$str = "Albert Einstein said: 'E=MC²'";
echo
html_entity_decode($str, ENT_COMPAT); // Will only convert double quotes
echo "<br>";
echo html_entity_decode($str, ENT_QUOTES); // Converts double
and single quotes
echo "<br>";
echo html_entity_decode($str, ENT_NOQUOTES); // Does not
convert any quotes
?>
उपरोक्त कोड का HTML आउटपुट होगा (स्रोत देखें):
Albert Einstein said: 'E=MC²'<br>
Albert Einstein said: 'E=MC²'<br>
Albert Einstein said: 'E=MC²'
उपरोक्त कोड का ब्राउज़र आउटपुट होगा:
Albert Einstein said: 'E=MC²'
Albert Einstein said: 'E=MC²'
Albert
Einstein said: 'E=MC²'
उदाहरण
पश्चिमी यूरोपीय वर्ण-सेट का उपयोग करके कुछ HTML निकायों को वर्णों में बदलें:
<?php
$str = "My name is Øyvind Åsane. I'm Norwegian.";
echo html_entity_decode($str, ENT_QUOTES, "UTF-8");
?>
उपरोक्त कोड का HTML आउटपुट होगा (स्रोत देखें):
My name is Øyvind Åsane. I'm Norwegian.
उपरोक्त कोड का ब्राउज़र आउटपुट होगा:
My name is Øyvind Åsane. I'm Norwegian.
❮ पीएचपी स्ट्रिंग संदर्भ