Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Diamond_PHP

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>\n";
   
   $n=10;
   for ($i=1;$i<=$n;$i++)
   
   {
       
     
     for ($j=$n-$i;$j>0;$j--)
     
     {
         
         echo " ";
         
     }
     
     for ($j=1;$j<=(2*$i-1);$j++)
     {
         
         echo "*";
         
     }
     
     echo "\n";
       
       
   }
   
   $h=1;
   
   for ($i=1;$i<$n;$i++)
   {
       
       for ($k=1;$k<=$h;$k++)
       
       {
           echo " ";
           
         
       }
       
       $h++;
       
       for ($j=1;$j<(2*($n-$i));$j++)
       
       {
           
           echo "*";
       }
       
       echo "\n";
   }
   
   
   
   
   
?>
</body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.