I'm going to ask a strange question. I'm using this code and it works, but I don't understand why. I'm new to php, and am just learning the syntax. This syntax looks wrong to me....but it works. I ask because I'm trying to write another conditional statement and using this as a model...
What I don't understand is...why is ?> at the beginning and<?php at the end of the internal statements?
It's just closing the php interpreter to spill out some html, and then reopening it.
If you don't know how code works, just play with it. For example, get rid of all the php start and stops. Then, put all the html tags in something like this:
Breaking that snippet down, here's a pseudo-code version. Opening and closing PHP tags, <?php and ?>, need to be included around everything that is php code, so the server understands how to process it correctly:
<?php if (current page is home page) { ?>
... normal html code here... (only shows up if the current page is the home page)
<?php } else (if the current page is not the home page) { ?>
... more normal html code... (only shows up if the current page is not the home page)
I'm new to php, and am just learning the syntax. This syntax looks wrong to me....but it works.
I ask because I'm trying to write another conditional statement and using this as a model...
What I don't understand is...why is ?> at the beginning and<?php at the end of the internal statements?
If you don't know how code works, just play with it. For example, get rid of all the php start and stops. Then, put all the html tags in something like this:
echo "<html_tags>Go in double quotes</html_tags";
The only way to learn to code is to experiment.
http://www.w3schools.com/php/php_if_else.asp