Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Can someone tell me what this means?

    This code appears at the top of my "header" before the:

    <html> tags.

    Code:
    <?
      $class = array();
      if (isset($menu)) {
        $class[$menu] = " class=\"selected\" ";
        
      }
      if ($menu == "contact") 
        $class["contact"] = " class=\"selected last\"";
      else
        $class["contact"] = " class=\"last\"";
      
    ?>
    Is it important? How can it even be "read" by web browsers if it is before the HTML tags?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,455
    Thanks
    0
    Thanked 632 Times in 622 Posts
    Quote Originally Posted by jump View Post
    This code appears at the top of my "header" before the:

    <html> tags.

    Code:
    <?
      $class = array();
      if (isset($menu)) {
        $class[$menu] = " class=\"selected\" ";
        
      }
      if ($menu == "contact") 
        $class["contact"] = " class=\"selected last\"";
      else
        $class["contact"] = " class=\"last\"";
      
    ?>
    Is it important? How can it even be "read" by web browsers if it is before the HTML tags?
    That looks like PHP - the way it is coded provided shorttags is enabled that code will be run before the page is sent to the browser. The values set in the array are probably being substituted into the HTML lower down in the page and attach classes to the spots where they are being applied that will affect how those parts of the page look.

    That code should not be sent to the web browser and so the web browser will not do anything with what it didn't get.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well initially my website was set up to draw code from a header (where that code was find) that contained all of the top-level tags (HTML, HEAD, BODY,etc.) but I had to copy and paste all of the text within the HTML tags because this didn't allow for title tag customization among other things. So I can just disregard this, correct?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •