PHP html_entity_decode() ফাংশন
প্রয়োগ
প্রদেয় HTML এনটিটি "<" (ছোট নকশা) এবং ">" (বড় নকশা) অক্ষরে রূপান্তর করা হবে:
<?php $str = "This is some <b>bold</b> text."; echo htmlspecialchars_decode($str); ?>
The HTML output of the above code is as follows (view source code):
<!DOCTYPE html> <html> <body> This is some <b>bold</b> text. </body> </html>
Browser output of the above code:
This is some bold text.
সংজ্ঞা ও ব্যবহার
htmlspecialchars_decode() ফাংশন প্রদেয় HTML এনটিটিকে অক্ষরে রূপান্তর করে।
ডিকোড করা হবের HTML এনটিটি:
- & ডিকোড করা হবে & (অপরিবর্তনশীল)
- " ডিকোড করা হবে " (ডবল কোটা)
- ' ডিকোড করা হবে ' (সিঙ্গল কোটা)
- < ডিকোড করা হবে < (ছোট নকশা)
- > ডিকোড করা হবে > (বড় নকশা)
htmlspecialchars_decode() ফাংশন হল htmlspecialchars() ফাংশনের পরকরণকারী।
সিন্ট্যাক্স
htmlspecialchars_decode(string,flags)
পারামিটার | বর্ণনা |
---|---|
string | অপরিহার্য।ডিকোড করতে হলের কোডটি নির্ধারণ করা। |
flags |
অপশনাল।কোটা কিভাবে প্রক্রিয়াকরণ করা এবং কোনও ডকুমেন্ট টাইপ ব্যবহার করা নির্ধারণ করা। ব্যবহৃত কোটা ধরন:
ব্যবহৃত ডকুমেন্ট টাইপের অতিরিক্ত ফ্ল্যাগস:
|
Technical Details
Return Value: | Return the converted string. |
PHP Version: | 5.1.0+ |
Update Log: |
In PHP 5.4, additional flags were added to specify the document type to be used:
|
More Examples
Example 1
Convert predefined HTML entities to characters:
<?php $str = "Bill & 'Steve'"; echo htmlspecialchars_decode($str, ENT_COMPAT); // Convert only double quotes echo "<br>"; echo htmlspecialchars_decode($str, ENT_QUOTES); // Convert double quotes and single quotes echo "<br>"; echo htmlspecialchars_decode($str, ENT_NOQUOTES); // Do not convert any quotes ?>
The HTML output of the above code is as follows (view source code):
<!DOCTYPE html> <html> <body> Bill & 'Steve'<br> Bill & 'Steve'<br> Bill & 'Steve' </body> </html>
Browser output of the above code:
Bill & 'Steve' Bill & 'Steve' Bill & 'Steve'
Example 2
Convert predefined HTML entities to double quotes:
<?php $str = 'I love "PHP".'; echo htmlspecialchars_decode($str, ENT_QUOTES); // Convert double quotes and single quotes ?>
The HTML output of the above code is as follows (view source code):
<!DOCTYPE html> <html> <body> I love "PHP". </body> </html>
Browser output of the above code:
I love "PHP".