开发者

PHP naming conventions? [closed]

开发者 https://www.devze.com 2023-03-10 02:16 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_StackOverflow中文版 Closed 11 years ago.

I'm coding smt right now, and am a little bit peeved by the fact that PHP sometimes calls its functions with underscore, and sometimes as one word. What's up with that?

Example:

int strlen(string $str)

and

bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )

I'm hoping that there is a good reason for this, and would really like to know what it is.


Quoted from: http://tnx.nl/php.html

PHP has inconsistent function naming
There is no apparent system in underscore(s) versus no underscore(s):

underscore               no underscore:

stream_get_line          readline
disk_free_space          diskfreespace
is_object                isset
mcal_day_of_week         jddayofweek
set_error_handler        setlocale
snmp_get_quick_print     snmpget
get_browser              getallheaders
base64_encode            urlencode
image_type_to_mime_type  imagetypes
msql_num_fields          mysql_numfields
php_uname                phpversion
strip_tags               stripslashes
bind_textdomain_codeset  bindtextdomain
cal_to_jd                gregoriantojd
str_rot13                strpos


Welcome to php. This has been a topic so many times. Bottom line is, the only way to get over it is using a php centric ide/editor that suggests. By the way that is just half the problem you will also see functions where the order is oposite. Like

(mixed $needle , array $haystack)

and then

(array $haystack , string $needle)

So get used to it, or get out is the motto.

0

精彩评论

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