htmlspecialchars_decode_basic.phpt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test htmlspecialchars_decode() function : basic functionality
  3. --FILE--
  4. <?php
  5. /* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style])
  6. * Description: Convert special HTML entities back to characters
  7. * Source code: ext/standard/html.c
  8. */
  9. echo "*** Testing htmlspecialchars_decode() : basic functionality ***\n";
  10. // Initialise arguments
  11. //value initialized = Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. "double quoted string"
  12. $single_quote_string = "Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 25. 1111 &amp; 0000 = 0000. &quot; double quoted string &quot;";
  13. $double_quote_string = "Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 25. 1111 &amp; 0000 = 0000. &quot; double quoted string &quot;";
  14. // Calling htmlspecialchars_decode() with default arguments
  15. var_dump( htmlspecialchars_decode($single_quote_string) );
  16. var_dump( htmlspecialchars_decode($double_quote_string) );
  17. // Calling htmlspecialchars_decode() with optional 'quote_style' argument
  18. var_dump( htmlspecialchars_decode($single_quote_string, ENT_COMPAT) );
  19. var_dump( htmlspecialchars_decode($double_quote_string, ENT_COMPAT) );
  20. var_dump( htmlspecialchars_decode($single_quote_string, ENT_NOQUOTES) );
  21. var_dump( htmlspecialchars_decode($double_quote_string, ENT_NOQUOTES) );
  22. var_dump( htmlspecialchars_decode($single_quote_string, ENT_QUOTES) );
  23. var_dump( htmlspecialchars_decode($double_quote_string, ENT_QUOTES) );
  24. echo "Done";
  25. ?>
  26. --EXPECTF--
  27. *** Testing htmlspecialchars_decode() : basic functionality ***
  28. string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
  29. string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
  30. string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
  31. string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
  32. string(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. &quot; double quoted string &quot;"
  33. string(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. &quot; double quoted string &quot;"
  34. string(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
  35. string(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
  36. Done