TheFilmGod Posted February 15, 2007 Share Posted February 15, 2007 What's the difference between "echo + variable after" and just putting down a variable? For instance, when making Html links, do you use echo php variable or just the php variable. So when do you use echo and not? Quote Link to comment https://forums.phpfreaks.com/topic/38677-solved-echo/ Share on other sites More sharing options...
ShogunWarrior Posted February 15, 2007 Share Posted February 15, 2007 Well echo is a PHP statement to output whatever you want. I'm not sure what you mean by "just the php variable", you probably mean the short syntax: <div><?=$variable?></div> The previous code shows how the short tags can be used to output whatever is in them. You can use echo in other situations where you are doing more complicated output: <div> <?php foreach( $users as $user ) { echo $user . '<br />'; } ?> </div> For instance. Quote Link to comment https://forums.phpfreaks.com/topic/38677-solved-echo/#findComment-185750 Share on other sites More sharing options...
Lumio Posted February 15, 2007 Share Posted February 15, 2007 If you only want to write something, it's easier to use <?= $var ?> But if you want to write something out of a large php-block it's better to use echo... or... you can only use echo in php-blocks Quote Link to comment https://forums.phpfreaks.com/topic/38677-solved-echo/#findComment-185752 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.