Home > database >  Can you have an echo in a echo PHP
Can you have an echo in a echo PHP

Time:05-23

Im trying to get the second echo to echo out the message but the first echo dont let me. I know the second echo works and the first too but when I but them together it wont work. Also im new to this so help is appreciated.

echo
'<h1  >J!inder</h1> <br> 
<div  >
    
    'echo $create->profilerand();'
    </div>';

CodePudding user response:

use concat

echo
'<h1  >J!inder</h1> <br> 
<div  >
    
    ' . $create->profilerand(). '
    </div>';

CodePudding user response:

PHP automatically uses the original echo, so you don't need it when using a variable.

echo
'<h1  >J!inder</h1> <br> 
<div  >
    
    '.$create->profilerand().'
    </div>';

The code removes the echo and ;, then replaces it with . which is just the joining character. echo is just a print function, and prints it onto the page. You can't print a printer. This also means you can use variables in variables (e.g. $whatever = "Lorem ".$create->profilerand()." ipsum";).

  • Related