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!


Results 1 to 7 of 7

Thread: [PHP] "!"'s

  1. #1
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default [PHP] "!"'s

    PHP Code:
    if($data['username'] == $username){
                

    How would I make that code do tho following: if $data['username'] (doesn't equal) $username{ }.

    I know you have to use an exclamation mark somewhere (!) but I don't know where. +rep

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

    Latest Awards:

    Default

    Quote Originally Posted by BOX! View Post
    PHP Code:
    if($data['username'] == $username){
                

    How would I make that code do tho following: if $data['username'] (doesn't equal) $username{ }.

    I know you have to use an exclamation mark somewhere (!) but I don't know where. +rep
    != $username


    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
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    thanks.

  4. #4

    Default

    Just something you might want to take note on, when checking if something is true or false it is in fact quicker to use === compared to == and same applies with !== and !=, and I believe it would be a good practice to do so to micro-optimize in advance. Also some benchmarking I did also found that comparing a variable to a string with ===, compared to == is also faster but in the end it's up to you and the conditions you are faced with.

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

    Latest Awards:

    Default

    Quote Originally Posted by Iszak View Post
    Just something you might want to take note on, when checking if something is true or false it is in fact quicker to use === compared to == and same applies with !== and !=, and I believe it would be a good practice to do so to micro-optimize in advance. Also some benchmarking I did also found that comparing a variable to a string with ===, compared to == is also faster but in the end it's up to you and the conditions you are faced with.
    It's also not the same thing at all, === is a strict match where == is a regular match.

    $hello = 0;
    $hallo = '0';

    PHP Code:
    if( $hallo == $hello )
    {
            echo 
    'hello<br />';
    }
    if( 
    $hallo === $hello )
    {
            echo 
    'hallo<br />';

    You should be able to figure it out from that.


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

  6. #6

    Default

    I'm aware of this Jewish Bear. I do know what I'm talking about, the === operator matches the type too be it string, int, float, double, etc. Amazing that someone actually know's what they're talking abut before posting aye? In his case if he used === it would be plausible because they'll both be strings if I'm not mistaken.

    Example, just because I can. (Not Relevant)
    PHP Code:
    <?php

    $int 
    10;
    $float 10.0;

    if (
    $int === $float)
    {
      echo 
    "They're the same!";
    }

    ?>
    Edit: Just re-read my post (the prior one) no where did I say that they're the same thing. I was saying it was quicker to use the === operator when comparing true or false implying that true and false were not strings and they're both in the same form of true/false e.g. 1 and 0 or true and false. But no where did I say === and == are the same, so I don't know where you got this idea from.
    Last edited by Iszak; 17-11-2008 at 06:19 PM. Reason: added example

  7. #7
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    How many threads have you actually created?

    You should just read a few tutorials.

Posting Permissions

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