fork download
  1. <?php
  2.  
  3. // your code goes here
  4. function printPattern($num){
  5.  
  6.  
  7. $m = $num;
  8. for ($i = $num ; $i > 0; $i--){
  9.  
  10. if($i % 2 != 0){
  11. echo ' ';
  12.  
  13. for ($j = $num - $m; $j > 0; $j--){
  14. echo ' ';
  15. }
  16.  
  17. $m --;
  18. for ($j = 0; $j < $i; $j++){
  19. echo '*';
  20. }
  21.  
  22. echo "\n";
  23. }
  24.  
  25. }
  26. }
  27. printPattern($num);
Success #stdin #stdout #stderr 0.02s 25920KB
stdin
5
stdout
    
stderr
PHP Notice:  Undefined variable: num in /home/c9Bvkb/prog.php on line 27