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!


View Poll Results: Was this information helpful?

Voters
15. You may not vote on this poll
  • Yes - I want more!

    7 46.67%
  • No - Totally rubbish, GO HOME!

    8 53.33%
  • Yes/No - Could be better!

    0 0%
Page 1 of 5 12345 LastLast
Results 1 to 10 of 41
  1. #1
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default [Tutorial] - PHP ~ The Basics.

    "PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly."
    PHP is a server-side code, meaning its processed before you even see the page, client-side coding is like javascript, and is processed as/when the page is loaded - Correct me if I'm wrong.

    In order to start a PHP code, you have to use the correct syntax (The rules that must be followed to write properly structured code.) There are a few ways to start / end the PHP page, either: (I use the first one.)


    PHP Code:
    <?
    ?>
    or

    PHP Code:
    <?php
    ?>
    All PHP pages, have to end with the ".php" extension, if not the code won't work. EG: if your page is "index.html" and contains PHP then rename it to "index.php"

    Echos
    Lets just say, its basically like "Shouting", onto a page... There are different ways to echo

    PHP Code:
    <?
    echo("Hello World!");
    ?>
    PHP Code:
    <?
    echo "Hello World";
    ?>
    Different people use different methods, but at the end of the day they both do the same principle.

    Try making a page called "driftpanzy.php" - Please check if you have PHP installed on your server/hosting or just ask me for 10MB Hosting + 100MB Bandwidth free of charge, TOS applies

    Once you've made the file, try doing HTML + PHP, I don't recommend building big systems like this, but you can get the hang of it.

    PHP Code:
    <html>
    <head>
    <title>PHP DriftPanzy</title>
    </head>
    <body>
    <?
    echo("Hello World");
    ?>
    </body>
    </html>
    It will display:
    Hello World
    Semicolons...
    Semicolon ends a line of PHP code, signifying the end of a PHP statement and should never be forgotten. EG: If we repeated "Hello World" code several times, then we would need to place semicolons at the end of each statement

    PHP Code:
    <html>
    <head>
    <title>PHP DriftPanzy</title>
    </head>
    <body>
    <?
    echo("Hello World");
    echo(
    "Hello World");
    echo(
    "Hello World");
    echo(
    "Hello World");
    ?>
    </body>
    </html>
    Hello WorldHello WorldHello WorldHello World
    You can add "<br>" after the Hello World, before the LAST quotation.

    Variables
    A variable is a means of storing temporary data, such as a text string "Hello World" or an integer value. A variable can be reused throughout the coding process, to define a variable try the following...



    PHP Code:
    <?
    $newvar 
    "Hello World";
    ?>
    You can call $newvar anything, but has to start with a dollar sign ($)

    You can also use the echo feature above on it, eg:

    PHP Code:
    <?
    $newvar 
    "Hello World";
    echo(
    $newvar);
    ?>
    Displays:
    Hello World
    As you can see I didn't include the quotations, i've just placed the var in, if you want to include text/html into the echo you can do this



    PHP Code:
    <?
    $newvar 
    "Hello World";
    echo(
    "<br>".$newvar." World is great");
    ?>
    Displays:
    Hello World World is great
    A bit more information on variables
    • Must start with a letter or underscore "_".
    • May only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ .
    • Variables with more than one word should be separated with underscores. $my_variable
    • Variables with more than one word can also be distinguished with capitalization. $myVariable
    You've covered today: Basic PHP; Echos, showing information on the page; Variables/Strings, how to store temporary data to use later on in the php page.

    Any more help just e-mail me! [email protected]
    Depending on how much views and how much I help people, I will continue explaining how EASY PHP really is!

    Edited by Favourtism (Forum Super Moderator): Thread Closed to avoid constant arguing.
    Last edited by Favourtism; 12-03-2008 at 05:01 PM.
    Hi, names James. I am a web developer.

  2. #2
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Until you use <?php your code will never be considered "good", <?php works on all servers with php installed while <? does not


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  3. #3
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    <?php doesn't work on all servers nor does <? - You have to have PHP installed. The latest version of PHP does support it and most hosts usually update their PHP version straight away, But seeing as its just a few letters between being "Good" and "Bad", I must feel so bad not to add them chars. Its not the PHP start tags that make you good, its the logic behind your coding.
    Last edited by Protege; 11-03-2008 at 06:51 PM.
    Hi, names James. I am a web developer.

  4. #4
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    <?php DOES work on all servers. <? is only works if it is allowed in php.ini

    Quote Originally Posted by DriftPanzy View Post
    <?php doesn't work on all servers nor does <? - You have to have PHP installed + the latest version of PHP does actually support it - seeing as its just a few more letters = doesn't make you better in any sort of way if you add another extra 3 characters to a line of code.

  5. #5
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    So your saying, I will buy a linux box and PHP will just magically work? - Please amuse me? or I will buy a nice windows box, and I will just magically have PHP working... again amuse me. Pointless arguement against a 3 letter addon to the start tags.
    Hi, names James. I am a web developer.

  6. #6
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    By all servers I actually ment server with PHP smart *bottom* ''/ I can also be a smart *bottom* as well: Some linux distributions actually do some with PHP installed and ready to use.

    Also it is not pointless. Its considered a unoffical standard to use <?php.

    Quote Originally Posted by DriftPanzy View Post
    So your saying, I will buy a linux box and PHP will just magically work? - Please amuse me? or I will buy a nice windows box, and I will just magically have PHP working... again amuse me. Pointless arguement against a 3 letter addon to the start tags.

  7. #7
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    Quote Originally Posted by Lolcopters View Post
    Until you use <?php your code will never be considered "good", <?php works on all servers with php installed while <? does not
    Quote Originally Posted by DriftPanzy View Post
    <?php doesn't work on all servers nor does <? - You have to have PHP installed. The latest version of PHP does support it and most hosts usually update their PHP version straight away, But seeing as its just a few letters between being "Good" and "Bad", I must feel so bad not to add them chars. Its not the PHP start tags that make you good, its the logic behind your coding.
    Quote Originally Posted by DriftPanzy View Post
    So your saying, I will buy a linux box and PHP will just magically work? - Please amuse me? or I will buy a nice windows box, and I will just magically have PHP working... again amuse me. Pointless arguement against a 3 letter addon to the start tags.

    Now lets see, If you actually read Lolcopters post you would have clearly noticed that he said "<?php works on all servers with php installed while <? does not "

    You see that bit, servers with PHP installed (Look, I even coloured it red for you!) Obviously PHP wont just magically work, It has to be installed.

    Please do a little bit of reading of what has actually been said before you try talking down to people such as Tomm and other people who know what they are talking about.

    .:; Johno

  8. #8
    Join Date
    Mar 2008
    Posts
    173
    Tokens
    0

    Default

    Quote Originally Posted by DriftPanzy View Post
    PHP is a server-side code, meaning its processed before you even see the page, client-side coding is like javascript, and is processed as/when the page is loaded - Correct me if I'm wrong.

    In order to start a PHP code, you have to use the correct syntax (The rules that must be followed to write properly structured code.) There are a few ways to start / end the PHP page, either: (I use the first one.)


    PHP Code:
    <?
    ?>
    or

    PHP Code:
    <?php
    ?>
    All PHP pages, have to end with the ".php" extension, if not the code won't work. EG: if your page is "index.html" and contains PHP then rename it to "index.php"

    Echos
    Lets just say, its basically like "Shouting", onto a page... There are different ways to echo

    PHP Code:
    <?
    echo("Hello World!");
    ?>
    PHP Code:
    <?
    echo "Hello World";
    ?>
    Different people use different methods, but at the end of the day they both do the same principle.

    Try making a page called "driftpanzy.php" - Please check if you have PHP installed on your server/hosting or just ask me for 10MB Hosting + 100MB Bandwidth free of charge, TOS applies

    Once you've made the file, try doing HTML + PHP, I don't recommend building big systems like this, but you can get the hang of it.

    PHP Code:
    <html>
    <head>
    <title>PHP DriftPanzy</title>
    </head>
    <body>
    <?
    echo("Hello World");
    ?>
    </body>
    </html>
    It will display:
    Semicolons...
    Semicolon ends a line of PHP code, signifying the end of a PHP statement and should never be forgotten. EG: If we repeated "Hello World" code several times, then we would need to place semicolons at the end of each statement

    PHP Code:
    <html>
    <head>
    <title>PHP DriftPanzy</title>
    </head>
    <body>
    <?
    echo("Hello World");
    echo(
    "Hello World");
    echo(
    "Hello World");
    echo(
    "Hello World");
    ?>
    </body>
    </html>
    You can add "<br>" after the Hello World, before the LAST quotation.

    Variables
    A variable is a means of storing temporary data, such as a text string "Hello World" or an integer value. A variable can be reused throughout the coding process, to define a variable try the following...



    PHP Code:
    <?
    $newvar 
    "Hello World";
    ?>
    You can call $newvar anything, but has to start with a dollar sign ($)

    You can also use the echo feature above on it, eg:

    PHP Code:
    <?
    $newvar 
    "Hello World";
    echo(
    $newvar);
    ?>
    Displays:
    As you can see I didn't include the quotations, i've just placed the var in, if you want to include text/html into the echo you can do this



    PHP Code:
    <?
    $newvar 
    "Hello World";
    echo(
    "<br>".$newvar." World is great");
    ?>
    Displays:
    A bit more information on variables
    • Must start with a letter or underscore "_".
    • May only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ .
    • Variables with more than one word should be separated with underscores. $my_variable
    • Variables with more than one word can also be distinguished with capitalization. $myVariable
    You've covered today: Basic PHP; Echos, showing information on the page; Variables/Strings, how to store temporary data to use later on in the php page.

    Any more help just e-mail me! [email protected]
    Depending on how much views and how much I help people, I will continue explaining how EASY PHP really is!
    That is awful structured code, its ugly.

    Plus, you shouldn't ever teach users to use short tags, <? instead of <?php or <%.

    Quit using ('s. You don't need them most of the time. You can easily do:

    PHP Code:
    <?php
    echo $variable;
    ?>
    Without them.


    You don't need a semicolon at the end of everything, or every statement..

    example:

    PHP Code:
    <?php
    if( $variable == "Something") {
         echo 
    "Hello" $variable;
    }
    ?>

    You use brackets, and lots of other things.

    You do not have to have the extension .php, my site uses .do and .ko also .php4, .php3, .php2, .php5, .phps

  9. #9
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    If you want to be a little **** and try be a sarcastic ****, I will treat you like a little **** "all servers" quoted by your lovely friend "Lolcopters", I stated that it wouldn't be on all servers and gave an example.
    Difference between <? and <?php ? - both start/end tags for a PHP page and one has 3 extra characters signifying the language, I'm so sincerely sorry for "Talking down" to people such as "Tomm" as I honor them in all their glory and suck up to them like a mouth to a Pepsi bottle, as they know what they are talking about and I clearly don't know at all, I clearly attempted to teach people a little PHP but you wish to start a confrontation over a little bit of coding differentiation, but seeing as I'm trying to tell the forum a easier way to learn PHP for the people who can't already get their heads round it and then get told I'm wrong in all ways, I never asked for criticisms and I never said which way was right, I said "(I use the first one.)" I never told you guys to use it, I just said "(I use the first one.)" So maybe read before you talk as "ActiveVision" said. I accept comments from people who know what they are saying, not suck ups and sarcastic screw heads. No criticisms to anyone else but ActiveVision
    Hi, names James. I am a web developer.

  10. #10
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    I said statements not "if statements" or "while statements", short tags can be taught to anyone, theres different ways people do things and thats how I do it, and it works at the end of the day, I'm not teaching people who already know I'm teaching people who want to know.

    Edited by Favourtism (Forum Super Moderator): Please do not double post.
    Last edited by Favourtism; 12-03-2008 at 04:56 PM.
    Hi, names James. I am a web developer.

Page 1 of 5 12345 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
  •