Page 2 of 5 FirstFirst 12345 LastLast
Results 11 to 20 of 46
  1. #11
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    There is a fine line between preference and just plain doing it wrong.

    For example, $variable['wat'] against $variable["wat"] is a preference. If you choose to use single quotes, then yes, that's more efficient. But it doesn't make using speech marks (") wrong.
    But do you think it's bad practice?
    How could this hapen to meeeeeeeeeeeeeee?lol.

  2. #12
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Excellent2 View Post
    Print isn't really a function as it doesn't require parenthesis to work, you should know that charlie:rolleyes:
    print() is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list. (php.net/print)

    Thats my point?

    Excellent, this isn't a "coding war", I asked for opinions on coding preference, not the different between print and echo.
    Last edited by Hypertext; 23-09-2008 at 10:40 PM.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  3. #13
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    For a smaller script, no, as with a smaller script it's going to slow the page down by a tiny percentage (I'm talking 0.x%). So using " over ' is just preference as it doesn't make any noticable differences to the page load.

    Though, with a larger script, yes, of course. As there will be more things to process, thus increasing the page loading time by a higher percentage causing the page to be a bit more inefficient.
    Last edited by Invent; 23-09-2008 at 10:40 PM.

  4. #14
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Hypertext View Post
    (it is a language construct)
    As is echo();

    EDIT: But Invent! I'm sure you know if you timed a script with 1000 lines in it (no white space) and using print(); you'd probably only see a second or so time difference?
    Last edited by Excellent2; 23-09-2008 at 10:41 PM.
    Back for a while.

  5. #15
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by Hypertext View Post
    Hi guys.

    I'm making this thread in response to the huge mass of people responding when confronted with bad coding practices, or bad ways of doing something, who respond with "it's my preference".

    It's becoming an excuse which is really invalid.

    I mean theres some situations where it doesn't matter, but most of the time, it is bad.

    For instance I've seen some people doing $_GET["my_property"], when you should use $_GET['my_property']. Even if you explain it to them, they just say it's "preference".

    Another big one, is using parenthesis in language constructs, this is a real big one. Many people say it's down to "preference" once again, but on the PHP website they explain that it does slow code down. Then you'll have people retort with "only on a big website". And that's usually where it comes to a head, as there isn't much of an argument against that, of which I can see. Although I believe regardless of traffic size, it still matters.

    So what are your views on this?

    Charlie.
    $_GET[ "header" ] and $_GET[ 'header' ] are the same things..

    '' is used for simple strings, "" used as a simple string and is the only string delimiter that supports inline values.

    Since PHP is derived from C, '' was originally used for one character (not even a string, as it is used in PHP.. but since PHP doesn't worry much about data types, it doesn't care)

    When PHP evolved, '' was considered to be a character delimiter, whereas "" was used as a string.

    It all depends on the situation, if people want to use $_GET[ "header" ] or $_GET[ 'header' ], it's their choice in this situation.

    Quote Originally Posted by Hypertext View Post
    Your point is completely invalid, as print is different to echo in many ways. Look it up if you want. :rolleyes:

    I actually talked about some peoples methods are valid, but the majority, there is a faster way to do something, which you should use.
    How is print different to echo in many ways? Other then the params, the only difference in print returns a value..

  6. #16
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    $_GET[ "header" ] and $_GET[ 'header' ] are the same things..

    '' is used for simple strings, "" used as a simple string and is the only string delimiter that supports inline values.

    Since PHP is derived from C, '' was originally used for one character (not even a string, as it is used in PHP.. but since PHP doesn't worry much about data types, it doesn't care)

    When PHP evolved, '' was considered to be a character delimiter, whereas "" was used as a string.

    It all depends on the situation, if people want to use $_GET[ "header" ] or $_GET[ 'header' ], it's their choice in this situation.



    How is print different to echo in many ways? Other then the params, the only difference in print returns a value..
    It wasn't the best example, but this still is bad coding practice as it does slow down scripts. But, yes, I admit, in that situation it probably is up to preference.

    Heres a list php link to about differences between echo and print. http://www.faqts.com/knowledge_base/...l/aid/1/fid/40
    How could this hapen to meeeeeeeeeeeeeee?lol.

  7. #17
    Join Date
    Nov 2005
    Location
    Edinburgh
    Posts
    11,690
    Tokens
    0
    Habbo
    Pyroka

    Latest Awards:

    Default

    Quote Originally Posted by Excellent2 View Post
    Did you take a second to read what I put? I said SMALL scripts. If you're coding a big script then of course echo would be the best method to use. No, I just happen to know that you come into this section from your beloved spam and try act like you know how it works.
    Just small scripts? So you're picking at Hypertext because he's generalized PHP scripts in his post, and you have to pick at it and say that he's totally wrong, it doesn't matter, few MS doesn't matter & that he should grow up... because you're just saying about small scripts.

    Damn, you are more ignorant than I. Achievement + 1.

  8. #18
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    ...wait a second. I think we've all forgot the most important topic/question - why is Pyroka in the web dev. forums?!
    Last edited by Invent; 23-09-2008 at 10:48 PM.

  9. #19
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    ...wait a second. I think we've all forgot the most important topic/question - why is Pyroka in the web dev. forums?!
    LOL!

    +rep.

    Pyroka was nerdy in class...but not that nerdy.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  10. #20
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by Hypertext View Post
    It wasn't the best example, but this still is bad coding practice as it does slow down scripts. But, yes, I admit, in that situation it probably is up to preference.

    Heres a list php link to about differences between echo and print. http://www.faqts.com/knowledge_base/...l/aid/1/fid/40
    It is not "bad coding practice" to use "" instead of ''.

    Here are some benchmarks:

    echo:

    3.1000000000003E-5 - ''
    3.1000000000003E-5 - ""
    3.299999999995E-5 - ('')
    2.9000000000001E-5 - ("")

    print:
    3.7000000000009E-5 - ''
    3.5000000000007E-5 - ""
    3.4000000000006E-5 - ('')
    3.3000000000061E-5 - ("")
    $_GET[ "var" ]:
    2.2000000000022E-5
    $_GET[ 'var' ]:
    3.3000000000061E-5
    It's a matter of preference for things like this, there's times to use '', and times to use "", it's only a bad coding practice to use them irresponsibly.


    I know the differences between them, and I told you.

Page 2 of 5 FirstFirst 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
  •