
But do you think it's bad practice?
How could this hapen to meeeeeeeeeeeeeee?lol.
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.
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.
Last edited by Excellent2; 23-09-2008 at 10:41 PM.
Back for a while.
$_GET[ "header" ] and $_GET[ 'header' ] are the same things..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.
'' 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.$_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..
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.
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.
...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.
It is not "bad coding practice" to use "" instead of ''.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
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 - ("")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.$_GET[ "var" ]:
2.2000000000022E-5
$_GET[ 'var' ]:
3.3000000000061E-5
I know the differences between them, and I told you.
Want to hide these adverts? Register an account for free!