php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78205 echo is not working
Submitted: 2019-06-25 10:06 UTC Modified: 2019-06-25 10:13 UTC
From: manojneed at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.1Git-2019-06-25 (Git) OS: window7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: manojneed at gmail dot com
New email:
PHP Version: OS:

 

 [2019-06-25 10:06 UTC] manojneed at gmail dot com
Description:
------------
Hi,
using PHP Version 7.1.12 when i am tring to printing Pattern 

like
     *
    * *
   * * *
  * * * *
 * * * * *


my code
<?php

for($i=1;$i<=5;$i++){
for($k=5;$k>$i;$k--){
echo " ";
//echo " ";
}
for($j=1;$j<=$i;$j++){
echo "*" ;
}
print "<br/>";
}
?>

in the second loop my first echo giving me output like

*
**
***
****
*****
which is not as expected

when i go with second echo code below

for($i=1;$i<=5;$i++){
for($k=5;$k>$i;$k--){
//echo " ";
echo " ";
}
for($j=1;$j<=$i;$j++){
echo "*" ;
}
print "<br/>";
}
?>
i get my desired output like



    *
   **
  ***
 ****
*****

strange both echo syntax is same why first echo not working.please help me 

Test script:
---------------
    *
   **
  ***
 ****
*****


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-25 10:13 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2019-06-25 10:13 UTC] requinix@php.net
The second is using a non-breaking space. https://en.wikipedia.org/wiki/Non-breaking_space

Replace the
  echo " ";
with
  echo "&nbsp;";
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 09:01:32 2025 UTC