I'm developing my a web application.
I have this piece of code:
if($_SESSION['add'] == 1)
echo '<input type="button" name="add" id="add" value="Add" onclick="add()" >';
if($_SESSION['edit'] == 1)
echo '<input type="button" name="edit" id="edit" value="Edit" onclick="edit()">';
While conditions in View are perfectly fine, your View should not be fetching data from any source by itself and it should only work on data your Controller (or Presenter, depending on whatever is your application architecture) feed it with. In this case your Controller should check
$_SESSION and make the decision what mode your View should display and pass that decision to your View for execution (i.e.
edit|add), but your View shouldn't not know why it switches between
add modes. It only must know how to do that.
PS: I recommend to make a habit to always put code blocks (even one-liners) in