Convert some predefined HTML entities to characters: in PHP

Description

The following code shows how to convert some predefined HTML entities to characters:.

Example


  //w w w .ja  v  a2s  .c o  m
<?php
    $str = "HTML &amp; &#039;CSS&#039;";
    echo htmlspecialchars_decode($str, ENT_COMPAT); // Will only convert double quotes
    echo "<br>";
    echo htmlspecialchars_decode($str, ENT_QUOTES); // Converts double and single quotes
    echo "<br>";
    echo htmlspecialchars_decode($str, ENT_NOQUOTES); // Does not convert any quotes
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone