Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange ERROR: Same PHP code but different result in mac and windows machine

I have met a very strange bug. Given the same piece of code:

<?php session_start(); ?>
<?php if (!isset($_SESSION['email'])): ?>
<p><a href="admin_reg.php">Regsiter as admin</p>
<p><a href="student_reg.php">Register as student</p>
<p><a href="login.php">Log in</a></p>
<? else: ?>
<p><a href="logout.php">Log out</a></p>
<p><a href="group_create.php">Create group</a></p>
<p><a href="group_join.php">Join group</a></p>
<?php endif; ?>

My group mates and I run the same project on different machines (they use windows and I use mac). We all run it in the xampp and I get a normal result: Before authentication, just the first three links appear. But in their machines, all six links have shown on the page, which is impossible. Our PHP version are also the same: 5.6.1*. Do you have any idea about it? Thanks in advance!

like image 292
user5779223 Avatar asked Mar 13 '23 06:03

user5779223


1 Answers

Your else is using short tags, which may not be enabled on all servers. Change it to use the full php tag:

<?php else: ?>
like image 124
aynber Avatar answered Mar 15 '23 05:03

aynber