004.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. General function test
  3. --FILE--
  4. <?php
  5. echo "Before function declaration...\n";
  6. function print_something_multiple_times($something,$times)
  7. {
  8. echo "----\nIn function, printing the string \"$something\" $times times\n";
  9. for ($i=0; $i<$times; $i++) {
  10. echo "$i) $something\n";
  11. }
  12. echo "Done with function...\n-----\n";
  13. }
  14. function some_other_function()
  15. {
  16. echo "This is some other function, to ensure more than just one function works fine...\n";
  17. }
  18. echo "After function declaration...\n";
  19. echo "Calling function for the first time...\n";
  20. print_something_multiple_times("This works!",10);
  21. echo "Returned from function call...\n";
  22. echo "Calling the function for the second time...\n";
  23. print_something_multiple_times("This like, really works and stuff...",3);
  24. echo "Returned from function call...\n";
  25. some_other_function();
  26. ?>
  27. --EXPECT--
  28. Before function declaration...
  29. After function declaration...
  30. Calling function for the first time...
  31. ----
  32. In function, printing the string "This works!" 10 times
  33. 0) This works!
  34. 1) This works!
  35. 2) This works!
  36. 3) This works!
  37. 4) This works!
  38. 5) This works!
  39. 6) This works!
  40. 7) This works!
  41. 8) This works!
  42. 9) This works!
  43. Done with function...
  44. -----
  45. Returned from function call...
  46. Calling the function for the second time...
  47. ----
  48. In function, printing the string "This like, really works and stuff..." 3 times
  49. 0) This like, really works and stuff...
  50. 1) This like, really works and stuff...
  51. 2) This like, really works and stuff...
  52. Done with function...
  53. -----
  54. Returned from function call...
  55. This is some other function, to ensure more than just one function works fine...