how to use php in an echo with html

In a php file, I generate HTML content with an echo. My question is: how to use one for php in this echo.

example of how i try to do;

                echo
& # 39; for ($ i = 1; $ i <= 2; i ++) {& # 39;

test

& # 39;} & # 39;
& # 39;