<?=$var['info']?> VS <? echo {$var['info']}; ?> Which should I use? The first one is much sorter and works perfectly. Although if it works faster with echoing it, then I'll use that... What do you think? Also in a strings and queries, which is better to use: ".$var['info']." or {$var['info']} or $var[info]
watch out when using short tags "<?", as there's a chance your code might have to run on a server that doesn't have them enabled in the future. as far as ".$var." or {$var} goes, it wont make much difference. Just choose one you like and be consistent in using it.
There is no difference..the only difference would be if your servers' php ini file didn't have short tags set as on, though most usually do, i don't think windows servers have them on as default though.
you can either both of those codes but if you using php templating i prefer <?=$var['info']?> not to much code in it
Personally I prefer complete opening tags rather than short tags because some servers don't have it enabled. <?php echo $var['info']; ?> For string, personally I don't think they matter. I prefer concatenation using dot : ".$var['info']."
Ok. Thanks. Another one. Is there a difference between if(isset($rnd){} PHP: and if($rnd){} PHP: I just get those "Notice: Undefined index: $rnd" errors and when I use "isset" they seem to go away. Should I just ignore those errors? I turned all errors on and I'm trying to solve every one of them...
Yes there is. isset checks to see if that variable contains a value. If you don't use isset most likely will throw an error if the variable is not initialized yet.
So if we are checking if a post has been submitted or if a session variable exists there is no real reason to use isset ? if($_POST['submit']){ //Then the post has been submitted } if($_SESSION['auth']){ //Then the user has been logged in } PHP: Cause surley theres no way for these variables to have been created without a proper login or form submission, so there's no need for an isset check? Infact couldn't we shorten that down further and simply just say if($_POST){ //Then the post has been submitted } PHP: cause the post array woudln't have anything in if it hasnt been submitted