1--TEST-- 2get_meta_tags() tests 3--FILE-- 4<?php 5 6$filename = dirname(__FILE__)."/get_meta_tags.html"; 7 8$data = <<<DATA 9<meta name="author" content="name"> 10<meta name="keywords" content="php documentation"> 11<meta name="DESCRIPTION" content="a php manual"> 12<meta name="geo.position" content="49.33;-86.59"> 13</head> <!-- parsing stops here --> 14DATA; 15 16$data1 = <<<DATA 17<html> 18 <head> 19 <meta name="author" content="name"> 20 <meta name="keywords" content="php documentation"> 21 <meta name="DESCRIPTION" content="a php manual"> 22 <meta name="geo.position" content="49.33;-86.59"> 23 </head> 24 <body> 25 <meta name="author" content="name1"> 26 <meta name="keywords" content="php documentation1"> 27 <meta name="DESCRIPTION" content="a php manual1"> 28 <meta name="geo.position" content="49.33;-86.591"> 29 </body> 30</html> 31DATA; 32 33$data2 = <<<DATA 34<meta name="author" content="name" 35<meta name="keywords" content="php documentation"> 36DATA; 37 38$data3 = <<<DATA 39<meta <meta name="keywords" content="php documentation"> 40DATA; 41 42$data4 = <<<DATA 43<meta name="author" content="name" 44<meta name="keywords" content="php documentation" 45DATA; 46 47$array = array($data, $data1, $data2, $data3, $data4, "", "<>", "<meta<<<<<"); 48 49foreach ($array as $html) { 50 file_put_contents($filename, $html); 51 var_dump(get_meta_tags($filename)); 52} 53 54@unlink($filename); 55 56echo "Done\n"; 57?> 58--EXPECTF-- 59array(4) { 60 ["author"]=> 61 string(4) "name" 62 ["keywords"]=> 63 string(17) "php documentation" 64 ["description"]=> 65 string(12) "a php manual" 66 ["geo_position"]=> 67 string(12) "49.33;-86.59" 68} 69array(4) { 70 ["author"]=> 71 string(4) "name" 72 ["keywords"]=> 73 string(17) "php documentation" 74 ["description"]=> 75 string(12) "a php manual" 76 ["geo_position"]=> 77 string(12) "49.33;-86.59" 78} 79array(1) { 80 ["keywords"]=> 81 string(17) "php documentation" 82} 83array(1) { 84 ["keywords"]=> 85 string(17) "php documentation" 86} 87array(0) { 88} 89array(0) { 90} 91array(0) { 92} 93array(0) { 94} 95Done 96