highlight_file.phpt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. highlight_file() tests
  3. --INI--
  4. highlight.string=#DD0000
  5. highlight.comment=#FF9900
  6. highlight.keyword=#007700
  7. highlight.default=#0000BB
  8. highlight.html=#000000
  9. allow_url_include=1
  10. allow_url_fopen=1
  11. --FILE--
  12. <?php
  13. $filename = __DIR__."/highlight_file.dat";
  14. var_dump(highlight_file($filename));
  15. var_dump(highlight_file('data:,<?php echo "test"; ?>'));
  16. var_dump(highlight_file('data:,<?php echo "test ?>'));
  17. $data = '
  18. <?php
  19. class test {
  20. public $var = 1;
  21. private function foo() { echo "foo"; }
  22. public function bar() { var_dump(test::foo()); }
  23. }
  24. ?>';
  25. file_put_contents($filename, $data);
  26. var_dump(highlight_file($filename));
  27. @unlink($filename);
  28. echo "Done\n";
  29. ?>
  30. --EXPECTF--
  31. Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
  32. Warning: highlight_file(%shighlight_file.dat): Failed to open stream: No such file or directory in %s on line %d
  33. Warning: highlight_file(): Failed opening '%shighlight_file.dat' for highlighting in %s on line %d
  34. bool(false)
  35. <code><span style="color: #000000">
  36. <span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"test"</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">?&gt;</span>
  37. </span>
  38. </code>bool(true)
  39. <code><span style="color: #000000">
  40. <span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"test&nbsp;?&gt;</span>
  41. </span>
  42. </code>bool(true)
  43. <code><span style="color: #000000">
  44. <br /><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">test&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$var&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;function&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">()&nbsp;{&nbsp;echo&nbsp;</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">bar</span><span style="color: #007700">()&nbsp;{&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">test</span><span style="color: #007700">::</span><span style="color: #0000BB">foo</span><span style="color: #007700">());&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
  45. </span>
  46. </code>bool(true)
  47. Done