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 5 12345 LastLast
Results 1 to 10 of 44
  1. #1
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default hi here are some php things i want to tell you

    1) security comes before performance in all aspects of programming, php or not
    2) learn to love () ? : (ternary operator)
    3) use "and" and "or" instead of && and ||, much easier to read and understand, does exactly the same thing
    4) never use $_REQUEST, very easy to forge things
    5) "" and '' perform the same, stop being eejits and saying one performs faster than the other, they don't any more, use either
    6) use , instead of . in echo, it's faster
    7) use echo instead of print unless you want to hang on to the variable, it's faster
    8) use cookies instead of sessions unless you specifically need sessions
    9) use strstr instead of foreach / for loop for replacing things

    that is all you can go now


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

  2. #2
    Join Date
    May 2008
    Posts
    1,791
    Tokens
    0

    Latest Awards:

    Default

    completely went over my head.

  3. #3
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Lol it'll come in handy Im sure
    I think you should right a guide on PHP security Because the only things I know are stripslashes and mysql_real_escape_string, md5 and sha1 :L:L

    ?

  4. #4
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    There are some things I thought I should point out in your post.

    Number two it's really personal preference although I must agree that when assigning variables with the ternary operator it does look nicer.

    Number three is iffy, yes they're easier to read and understand, but there is a slight difference between them. The "&&" and "||" have a higher operator precedence than "AND" and "OR", but most people won't encounter a situation where this will be a problem.

    Number five is wrong, single quotes are faster unless you concatenate which then in most cases double quotes is faster. But the speed difference is negligible.

    Number seven is confusing, you say use echo instead of print unless you want to hang onto the variable? If you echo a variable, it doesn't unset it, same goes with print - either way you'll hang onto it.

    Number eight I can disagree with, because cookies can be more easily manipulated than sessions, so you need to justify when you should use cookies over sessions - and this contradicts with number one, as by using sessions it's more secure than cookies in most cases.


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

    Latest Awards:

    Default

    Quote Originally Posted by DeejayMachoo View Post
    There are some things I thought I should point out in your post.
    ok

    Quote Originally Posted by DeejayMachoo View Post
    Number three is iffy, yes they're easier to read and understand, but there is a slight difference between them. The "&&" and "||" have a higher operator precedence than "AND" and "OR", but most people won't encounter a situation where this will be a problem.
    Nobody will ever encounter a situation where that will be a problem, I can see no reason for it ever to be a problem ever.

    Quote Originally Posted by DeejayMachoo View Post
    Number five is wrong, single quotes are faster unless you concatenate which then in most cases double quotes is faster. But the speed difference is negligible.
    No. Single quotes are as fast as double quotes and vice-versa, I don't consider 0.007 seconds faster over 100,000 loop test to be faster, I consider it to be the same time.

    Quote Originally Posted by DeejayMachoo View Post
    Number seven is confusing, you say use echo instead of print unless you want to hang onto the variable? If you echo a variable, it doesn't unset it, same goes with print - either way you'll hang onto it.
    print holds the printed string in a variable, echo doesn't

    Quote Originally Posted by DeejayMachoo View Post
    Number eight I can disagree with, because cookies can be more easily manipulated than sessions, so you need to justify when you should use cookies over sessions - and this contradicts with number one, as by using sessions it's more secure than cookies in most cases.
    no they're not, cookies are just as secure as sessions if you know how to keep them secure, sessions are based on a cookie with the session id anyway


    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
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    1) security comes before performance in all aspects of programming, php or not
    Naturally.
    2) learn to love () ? : (ternary operator)
    Have married it.
    3) use "and" and "or" instead of && and ||, much easier to read and understand, does exactly the same thing
    Mm. Personal preferance IMO, I use | and & and they work fine.
    4) never use $_REQUEST, very easy to forge things
    mmhm.
    5) "" and '' perform the same, stop being eejits and saying one performs faster than the other, they don't any more, use either
    I think that ' looks nicer. Personal pref.
    6) use , instead of . in echo, it's faster
    How much faster?
    7) use echo instead of print unless you want to hang on to the variable, it's faster
    already do
    8) use cookies instead of sessions unless you specifically need sessions
    Use both...
    9) use strstr instead of foreach / for loop for replacing things
    fairs

    that is all you can go now
    CHEERS JEWISH BEAR.

  7. #7

    Default

    Quote Originally Posted by Jewish Bear View Post
    No. Single quotes are as fast as double quotes and vice-versa, I don't consider 0.007 seconds faster over 100,000 loop test to be faster, I consider it to be the same time.
    Although you may not consider it to be faster - it is faster none the less, but I agree with Matt, it's negligible.

    Quote Originally Posted by Jewish Bear View Post
    print holds the printed string in a variable, echo doesn't
    No it doesn't, It doesn't specify it in the documentation, I can't find it anywhere, prove me wrong?

    Quote Originally Posted by Jewish Bear View Post
    cookies are just as secure as sessions if you know how to keep them secure, sessions are based on a cookie with the session id anyway
    I'm not even going to argue with this - cookies shouldn't be used for sensitive data no matter how much you can "secure" it with encrypting or hashing and I think that's what Matt was getting at.

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

    Latest Awards:

    Default

    Quote Originally Posted by Iszak View Post
    Although you may not consider it to be faster - it is faster none the less, but I agree with Matt, it's negligible.
    0.007 over 100,000 loops is not faster in a real-world situation.


    Quote Originally Posted by Iszak View Post
    No it doesn't, It doesn't specify it in the documentation, I can't find it anywhere, prove me wrong?
    It returns 1 always, so you can set it in a variable, forgot to add "printed string 1" obviously >.>


    Quote Originally Posted by Iszak View Post
    I'm not even going to argue with this - cookies shouldn't be used for sensitive data no matter how much you can "secure" it with encrypting or hashing and I think that's what Matt was getting at.
    Awesome, you should stop using every forum and website in the world that uses cookies for sensitive data (which is: nearly every website that uses cookies).

    This forum, every forum you've ever been on. Cookies are as secure as the computer they're stored on, which in my case happens to be very.


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

  9. #9
    Join Date
    Feb 2008
    Posts
    333
    Tokens
    0

    Default

    Wow dan, not much more to teach someone in 10 seconds now is there?
    Thanks for these tips - They'll help with my PHP skills.

    Latest +rep recieved: Isolde
    Latest -rep recieved: Shizzle

    REP MEEEE


  10. #10

    Default

    Dan, grow the **** up - I don't know if it's just me, but I'm sick of your constant trolling, and pointless threads that seem as if they're just to get "praised" for a few hours of work.

    Don't bother replying to this, because I'm never going to reply to you again.

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
  •