The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End why does this work?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #28695

    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:

    echo "<html_tags>Go in double quotes</html_tags";

    The only way to learn to code is to experiment.


    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:


    … normal html code here… (only shows up if the current page is the home page)

    … more normal html code… (only shows up if the current page is not the home page)

    Viewing 3 posts - 1 through 3 (of 3 total)
    • The forum ‘Back End’ is closed to new topics and replies.