summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/strip_tags_basic1.phpt
blob: 6d98f47258657ef83321506e278133053cca77d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--TEST--
Test strip_tags() function : basic functionality - with default arguments
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string 
 * Source code: ext/standard/string.c
*/

echo "*** Testing strip_tags() : basic functionality ***\n";

// array of arguments 
$string_array = array (
  "<html>hello</html>",
  '<html>hello</html>',
  "<?php echo hello ?>",
  '<?php echo hello ?>',
  "<? echo hello ?>",
  '<? echo hello ?>',
  "<% echo hello %>",
  '<% echo hello %>',
  "<script language=\"PHP\"> echo hello </script>",
  '<script language=\"PHP\"> echo hello </script>',
  "<html><b>hello</b><p>world</p></html>",
  '<html><b>hello</b><p>world</p></html>',
  "<html><!-- COMMENT --></html>",
  '<html><!-- COMMENT --></html>'
);
  
  		
// Calling strip_tags() with default arguments
// loop through the $string_array to test strip_tags on various inputs
$iteration = 1;
foreach($string_array as $string)
{
  echo "-- Iteration $iteration --\n";
  var_dump( strip_tags($string) );
  $iteration++;
}

echo "Done";
?>
--EXPECTF--
*** Testing strip_tags() : basic functionality ***
-- Iteration 1 --
string(5) "hello"
-- Iteration 2 --
string(5) "hello"
-- Iteration 3 --
string(0) ""
-- Iteration 4 --
string(0) ""
-- Iteration 5 --
string(0) ""
-- Iteration 6 --
string(0) ""
-- Iteration 7 --
string(0) ""
-- Iteration 8 --
string(0) ""
-- Iteration 9 --
string(12) " echo hello "
-- Iteration 10 --
string(12) " echo hello "
-- Iteration 11 --
string(10) "helloworld"
-- Iteration 12 --
string(10) "helloworld"
-- Iteration 13 --
string(0) ""
-- Iteration 14 --
string(0) ""
Done