Have an account? Sign in
Login  Register  Facebook
Should I place everything in echo tags
A quick question involving PHP development, I seem to be wondering about this more and more as I develop more complex sites. Basically say we have a basic PHP / XHTML inbox (messaging system). I perform checks at the top (check if user is logged in, check if user has correct permissions etc). Then use the header(\'location:\') function if the authentication fails. The question is do I write the rest of the inbox code in a huge \'else\' block or just use standard html. I read somewhere about about it being bad to put any code after using the \'header\' function.
Started: September 16, 2011 Latest Activity: September 16, 2011 php xhtml
1 Answer
Just follow your header with
exit();
Than it won't be a problem. see third example here Also you don't need a big echo like that, you can echo html like this aswell if you want:
<?php
  //php stuff
  if(test){
?>

   html here

<?php
  }
  else{
?>

   other html

<?php
  }
?>

Posted: MacOS
In: September 16, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer