003.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --TEST--
  2. strip comments and whitespace with -w
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) == 'WIN') {
  6. die ("skip not for Windows");
  7. }
  8. include "skipif.inc";
  9. ?>
  10. --FILE--
  11. <?php
  12. include "include.inc";
  13. $php = get_cgi_path();
  14. reset_env_vars();
  15. $filename = __DIR__.'/003.test.php';
  16. $code ='
  17. <?php
  18. /* some test script */
  19. class test { /* {{{ */
  20. public $var = "test"; //test var
  21. #perl style comment
  22. private $pri; /* private attr */
  23. function foo(/* void */) {
  24. }
  25. }
  26. /* }}} */
  27. ?>
  28. ';
  29. file_put_contents($filename, $code);
  30. var_dump(`$php -n -w "$filename"`);
  31. var_dump(`$php -n -w "wrong"`);
  32. var_dump(`echo "<?php /* comment */ class test {\n // comment \n function foo() {} } ?>" | $php -n -w`);
  33. @unlink($filename);
  34. echo "Done\n";
  35. ?>
  36. --EXPECTF--
  37. string(%d) "X-Powered-By: PHP/%s
  38. Content-type: text/html%r; charset=.*|%r
  39. <?php
  40. class test { public $var = "test"; private $pri; function foo() { } } ?>
  41. "
  42. string(%d) "Status: 404 Not Found
  43. X-Powered-By: PHP/%s
  44. Content-type: text/html%r; charset=.*|%r
  45. No input file specified.
  46. "
  47. string(%d) "X-Powered-By: PHP/%s
  48. Content-type: text/html%r; charset=.*|%r
  49. <?php class test { function foo() {} } ?>
  50. "
  51. Done