Learning PHP
Posted: Thu Jul 22, 2010 10:11 am
Good evening,
I am still learning PHP, and while reading understanding one of the tutorials that was linked in this forum, I was caught with this code:
I do understand that the code's purpose is to check if the user's browser is IE or not. What I am very curious about is the way the code is written.
I am trying to learn how to write a good php code, and I have just stumbled on a tutorial the seems the code is not well-written (As for me since I am a newbie). Can anyone enlighten me on this?
I am still learning PHP, and while reading understanding one of the tutorials that was linked in this forum, I was caught with this code:
Code: Select all
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
{
?>
<h3>strpos() must have returned non-false</h3>
<p>You are using Internet Explorer</p>
<?php
}
else
{
?>
<h3>strpos() must have returned false</h3>
<p>You are not using Internet Explorer</p>
<?php
}
?>Code: Select all
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
{ -[b][i] why is this in between <?php ?> tags[/i][/b]
?>
<h3>strpos() must have returned non-false</h3>
<p>You are using Internet Explorer</p>
<?php
}
else
{
?>
<h3>strpos() must have returned false</h3>
<p>You are not using Internet Explorer</p>
<?php
} - [b][i]why is this in between <?php ?> tags[/i][/b]
?>