www.webdeveloper.com
Results 1 to 3 of 3

Thread: PHP Syntax Question

  1. #1
    Join Date
    Apr 2005
    Location
    Behind my DiGiCo SD7 Console
    Posts
    900

    PHP Syntax Question

    I'm having issues with the else command on this and was wondering what the correct syntax is:

    PHP Code:
    if ($_SERVER['SCRIPT_FILENAME'] ==  "/var/www/vhosts/mydomain.com/httpdocs/index.php"){
       echo 
    "<div class='home-nav'>
                <ul class='nav'>
                 <li><a href='index.php' title='Home' class='selected'><span>Home</span></a></li>
                    <li><a href='#' title='Renew'><span>Renew</span></a></li>
                    <li><a href='#' title='Status'><span>Status</span></a></li>
                    <li><a href='about.php' title='About Us'><span>About Us</span></a></li>
                    <li><a href='#' title='Support'><span>Support</span></a></li>
                    <li><a href='contact.php' title='Contact Us'><span>Contact Us</span></a></li>
                </ul>
                </div>;"
                
    else 
                       echo 
    "<div class='inner-nav'>
                <ul class='inner-nav'>
                 <li><a href='index.php' title='Home' class='selected'><span>Home</span></a></li>
                    <li><a href='#' title='Renew'><span>Renew</span></a></li>
                    <li><a href='#' title='Status'><span>Status</span></a></li>
                    <li><a href='about.php' title='About Us'><span>About Us</span></a></li>
                    <li><a href='#' title='Support'><span>Support</span></a></li>
                    <li><a href='contact.php' title='Contact Us'><span>Contact Us</span></a></li>
                </ul>
                </div>"
    ;
        
    }
    ?> 
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,330
    You need a closing brace before the else and an opening brace after it.
    PHP Code:
    if($condtion) {
       
    // commands
    }
    else {
       
    // commands

    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Aug 2006
    Posts
    1,908
    And this:
    Code:
                </div>;"
    should be this:
    Code:
                </div>";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles