开发者

Is using php shorthands bad? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Are PHP short tags acceptable to use?

I'm just learning php and (been learning for about 6 months) and in a tutorial that I'm going through, it's using ph开发者_如何转开发p shorthands, so when I looked it up on google, I came to this stack overflow question StackOverflow question where one of the popular answers says that shorthands are bad.

I know one of the following comments then suggest that it's not bad but I also remotely remember reading from a php book before that it's not always good to use them. So I'm a bit confused, are they bad or not?


It is generally a bad idea because of portability. All PHP configurations understand the <?php ?> tags, but not all are configured to use <? ?>.

Same thing goes for <? =$variable; ?> for printing.


They are not bad actually, but you can say that it's kinda a bit lazy sort of thing to do for a GOOD TECHNICAL programmer. Why I'm using this word "GOOD TECHNICAL" is because, since they know about the technicalities of PHP, then they should also know whether the shorthands will be of any use or not in the long run, whenever any adjustments is to be made regarding the fine tunings of the PHP Server.

But still, it's one of my views & may be it will not match with others' answers.


I personally never use them because I find it makes my code ugly, hard to read and harder to debug. I'm talking about shorthands like the one-line if statement. Not every PHP configuration understands short open and ending tags, and not every programmer knows about shorthand notation so this might be a problem if you want to share code at some point. I wouldn't advise using it.


the code "<? ?>" depends on the "php.ini", you should change the state short open tag. While the code "<?php ?>" can run everytime everywhere, without any configuration. I recommend you to use smarty template.It's perfectly easy to use. And code is beautiful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜