Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: PHP Includes.

  1. #1
    Join Date
    Jul 2004
    Location
    Bournemouth. UK
    Posts
    3,638
    Tokens
    0

    Latest Awards:

    Default PHP Includes.

    Hey.

    Im having trouble with these PHP includes i know where to put the codes and stuff.

    But i don't understand that " Case " Tag.

    If you could explain the whole lot fully it would help

    Thanks.

    Ross
    REMOVED

    Edited by jesus (Forum Super Moderator): Please do not have text in your signature which is over size 4.

  2. #2
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Umm case tag?

    php include all you need is.

    PHP Code:
    <?php
    include("somepage.htm");
    ?>

  3. #3
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Mentor

    php include all you need is.

    PHP Code:
    <?php
    include("somepage.htm");
    ?>
    Unless you mean one of the navigation systems, in wich it uses the case; tags to check for varibles etc.

    Athogh i personly find it far easyer just to use teh if tags

    aka
    PHP Code:
    <?php
    // get variable from url
    $item basename($item);

    // include pages depedning on if statement
    if($item == "pie") { include("piepage.htm"); }
    elseif(
    $item == "cheese") { include("chessepage.htm"); }
    elseif(
    $item == "cake") { include("mmmcake.htm"); }
    // if doesnt fit above go to this
    else { include("default.htm"); }

    ?>
    Edit by Urges - Please refrain from double posting. Simply edit your first one. Thankyou
    Last edited by Urges; 17-06-2005 at 01:05 PM.

  4. #4
    Join Date
    Jul 2004
    Location
    Bournemouth. UK
    Posts
    3,638
    Tokens
    0

    Latest Awards:

    Default

    So you don't have to use the case tag?

    And could you explain the above post in more detail please?
    REMOVED

    Edited by jesus (Forum Super Moderator): Please do not have text in your signature which is over size 4.

  5. #5
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    the good thing about php is theres usealy 3 or 4 ways of doing evrerything,
    case tags, if tags, (there is another one ive curantly forgotten)

    case tags is more confusing than the if tag, wich does quite litral what it says

    Ok, lets say a url to the page the below code is on is index.php?page=this

    To get the value of page, in to a variable
    PHP Code:
    $page basename($page); 
    Then the if statemnte comes in

    PHP Code:

    if($page=="cake")
    { echo 
    "mmm cake"; } 
    So splitting it up.

    if($page=="cake");

    Says if the varible page, holds the infomation cake . then it does whats between the {} tags after it, in this case echo out "mmmm cake"

    Then, to test for another possiblty in the same bit, you use the else if, wich is an exstntion on this if tag

    PHP Code:
    elseif($page == "pie") {echo "pie rules"; } 
    wich works in the same way as the if more aless, and can be used as many times as you like.

    so for exsample

    PHP Code:
    elseif($page == "wood") {echo "wood like it is"; }
    elseif(
    $page == "stone") {echo "seems rocky"; }
    elseif(
    $page == "egg") {echo "makes a meal out of anything"; } 
    Once you have all the possibltys you want, the you ad the end bit the else tag

    PHP Code:
    else {"ok i give up " ;} 
    which basicaly says, if non of the above match, use this.

    And thats more aless the whole of the if statment, with a basic use, you could include pages insted of echoing random comments for exsample.

    hope that helps.

    and here the full useless script here
    PHP Code:
    $page basename($page);

    if(
    $page=="cake") { echo "mmm cake"; }

    elseif(
    $page == "pie") {echo "pie rules"; }
    elseif(
    $page == "wood") {echo "wood like it is"; }
    elseif(
    $page == "stone") {echo "seems rocky"; }
    elseif(
    $page == "egg") {echo "makes a meal out of anything"; }

    else {
    "ok i give up " ;} 

  6. #6
    Join Date
    Jul 2004
    Location
    Sunshine Coast, Queensland, AU
    Posts
    1,830
    Tokens
    467

    Latest Awards:

    Default

    how do you had php to a page on frontpage

  7. #7
    Join Date
    Jul 2004
    Location
    Bournemouth. UK
    Posts
    3,638
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Mentor
    the good thing about php is theres usealy 3 or 4 ways of doing evrerything,
    case tags, if tags, (there is another one ive curantly forgotten)

    case tags is more confusing than the if tag, wich does quite litral what it says

    Ok, lets say a url to the page the below code is on is index.php?page=this

    To get the value of page, in to a variable
    PHP Code:
    $page basename($page); 
    Then the if statemnte comes in

    PHP Code:

    if($page=="cake")
    { echo 
    "mmm cake"; } 
    So splitting it up.

    if($page=="cake");

    Says if the varible page, holds the infomation cake . then it does whats between the {} tags after it, in this case echo out "mmmm cake"

    Then, to test for another possiblty in the same bit, you use the else if, wich is an exstntion on this if tag

    PHP Code:
    elseif($page == "pie") {echo "pie rules"; } 
    wich works in the same way as the if more aless, and can be used as many times as you like.

    so for exsample

    PHP Code:
    elseif($page == "wood") {echo "wood like it is"; }
    elseif(
    $page == "stone") {echo "seems rocky"; }
    elseif(
    $page == "egg") {echo "makes a meal out of anything"; } 
    Once you have all the possibltys you want, the you ad the end bit the else tag

    PHP Code:
    else {"ok i give up " ;} 
    which basicaly says, if non of the above match, use this.

    And thats more aless the whole of the if statment, with a basic use, you could include pages insted of echoing random comments for exsample.

    hope that helps.

    and here the full useless script here
    PHP Code:
    $page basename($page);

    if(
    $page=="cake") { echo "mmm cake"; }

    elseif(
    $page == "pie") {echo "pie rules"; }
    elseif(
    $page == "wood") {echo "wood like it is"; }
    elseif(
    $page == "stone") {echo "seems rocky"; }
    elseif(
    $page == "egg") {echo "makes a meal out of anything"; }

    else {
    "ok i give up " ;} 

    Ok. But why does it have to echo ?
    REMOVED

    Edited by jesus (Forum Super Moderator): Please do not have text in your signature which is over size 4.

  8. #8
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by iRoss
    Ok. But why does it have to echo ?

    echo basicly is just the function that tellls it to write to the page, aka

    echo "<b> Hello </b>";

    woudl just write on to the html page

    <b> Hello </b>

    echo, basicly prints the data.

    so it doesnt actaly have to be echo, you could put any other bit of php in the gaps to do, you could even ad another if statement if you wanted. or an include, for a navigation, or seting a varible, what ever you wanted realy. i just used the echo statemnte for the exsample


    Quote Originally Posted by phoenix-iv
    how do you had php to a page on frontpage

    front page is prettyy crapy, and i dont think it supports php, easyest just to do in notepad, as you cant get a proper visula pic of it anyway as it would need to genorate.

    then just save as the file .php , but in note pad put that in "" quote marks, so it chnages the file type rather than adding .txt to the end of it
    Last edited by Mentor; 17-06-2005 at 03:43 PM.

  9. #9
    Join Date
    Jul 2004
    Location
    Bournemouth. UK
    Posts
    3,638
    Tokens
    0

    Latest Awards:

    Default

    So if you leave the echo bits blank ( Because i don't really understand them ) Would it matter?

  10. #10
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    well the if statment would work, but when it came to the bits nothing would appear since theres nothing telling php to write anything

Page 1 of 2 12 LastLast

Posting Permissions

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