xref: /php-src/tests/func/004.phpt (revision d679f022)
1--TEST--
2General function test
3--FILE--
4<?php
5
6echo "Before function declaration...\n";
7
8function print_something_multiple_times($something,$times)
9{
10  echo "----\nIn function, printing the string \"$something\" $times times\n";
11  for ($i=0; $i<$times; $i++) {
12    echo "$i) $something\n";
13  }
14  echo "Done with function...\n-----\n";
15}
16
17function some_other_function()
18{
19  echo "This is some other function, to ensure more than just one function works fine...\n";
20}
21
22
23echo "After function declaration...\n";
24
25echo "Calling function for the first time...\n";
26print_something_multiple_times("This works!",10);
27echo "Returned from function call...\n";
28
29echo "Calling the function for the second time...\n";
30print_something_multiple_times("This like, really works and stuff...",3);
31echo "Returned from function call...\n";
32
33some_other_function();
34
35?>
36--EXPECT--
37Before function declaration...
38After function declaration...
39Calling function for the first time...
40----
41In function, printing the string "This works!" 10 times
420) This works!
431) This works!
442) This works!
453) This works!
464) This works!
475) This works!
486) This works!
497) This works!
508) This works!
519) This works!
52Done with function...
53-----
54Returned from function call...
55Calling the function for the second time...
56----
57In function, printing the string "This like, really works and stuff..." 3 times
580) This like, really works and stuff...
591) This like, really works and stuff...
602) This like, really works and stuff...
61Done with function...
62-----
63Returned from function call...
64This is some other function, to ensure more than just one function works fine...
65