Треугольник - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Треугольник.php

  1. <?php
  2. $char = '*';
  3. $height = 10;
  4. $indent = $height - 1;
  5. $space = '  ';
  6. $rightCountChar = 1;
  7.  
  8.  
  9. for($i = 1; $i <= $height; $i++){
  10.     echo str_repeat($space ,$indent);
  11.     echo str_repeat($char ,$i + $rightCountChar-1);
  12.     echo '<br>';
  13.     $indent--;
  14.     $rightCountChar++;
  15. }
  16.  
File Description
  • Треугольник
  • PHP Code
  • 05 Jan-2023
  • 285 Bytes
You can Share it: