SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    whts the reason behind it?

    i m learning php and i had this chuck of code
    Code PHP:
    <?php
    if(ISSET($_GET['category'])){
        $subj = $_GET['category'];
        [B]$pages = "";[/B]
    }elseif
        (ISSET($_GET['sub'])){
        $page = $_GET['sub'];
        [B]$subj="";[/B]
    }else{
     $subj="";
     $page="";    
    }
     
        ?>
    what i wanted to know why are the values empty and swaped in if and else if cases?
    All those who wander aren't lost.

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Can you elaborate on what you're trying to do?


    I noticed you have a variable $pages and a variable $page. Is there a typo?

    I would suggest initializing all your variables before the if-statements, rather than on the last else or within each if-statement. Then you would just set values to the ones you needed later. That's so you don't lose track of what variables were created where and what default value they were assigned.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Bookmarks

Posting Permissions

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