fork download
  1. <?php
  2. /******************************************************************************
  3.  
  4. Welcome to GDB Online.
  5. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
  6. C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
  7. Code, Compile, Run and Debug online from anywhere in world.
  8.  
  9. *******************************************************************************/
  10.  
  11. function pattern($n){
  12. if($n==1 || $n%2==0 || $n<0){
  13. echo "error";
  14. }
  15. else{
  16. for($i=0; $i<n+2; $i++){
  17. for($j=0; $j<=(($n+2)/2-1); $j++){
  18. echo " ";
  19. }
  20. echo "e\n";
  21. }
  22. for($j=0; $j<n; $j++){
  23. for($i=0; $i<$n+2; $i++){
  24. echo "*";
  25. }
  26. if($j==($n-1)/2){
  27. for($x=0; $x<$n+2; $x++){
  28. echo "e";
  29. }
  30. }
  31. else{
  32. echo " ";
  33. }
  34. echo "\n";
  35. }
  36. }
  37. }
  38.  
  39. echo pattern(9);
  40.  
Success #stdin #stdout #stderr 0.02s 25848KB
stdin
Standard input is empty
stdout
     e
     e
stderr
PHP Warning:  Use of undefined constant n - assumed 'n' (this will throw an Error in a future version of PHP) in /home/GwtKPx/prog.php on line 16
PHP Warning:  A non-numeric value encountered in /home/GwtKPx/prog.php on line 16
PHP Warning:  Use of undefined constant n - assumed 'n' (this will throw an Error in a future version of PHP) in /home/GwtKPx/prog.php on line 16
PHP Warning:  A non-numeric value encountered in /home/GwtKPx/prog.php on line 16
PHP Warning:  Use of undefined constant n - assumed 'n' (this will throw an Error in a future version of PHP) in /home/GwtKPx/prog.php on line 16
PHP Warning:  A non-numeric value encountered in /home/GwtKPx/prog.php on line 16
PHP Warning:  Use of undefined constant n - assumed 'n' (this will throw an Error in a future version of PHP) in /home/GwtKPx/prog.php on line 22