Naming functions in PHP [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I looked online and could not find any answer. I'm new to PHP and i've seen so many different ways of naming functions. Namely,
isset <- no underscore
is_integer <- underscore
fooBar <-subsequent words after the first have the first letter capitalized.
In what way do the functions differ in the way they work, such that they are named differently by convention? Or is it some other reason?

Earlier versions of PHP built-in functions had no naming conventions, that's why we have such a zoo. But, no, it does not matter how you name a function as long as you use naming conventions of your team.
If you're making shared public code/library you better stay close to, for example, http://www.php-fig.org/psr/psr-1/ PHP standards

Related

Why are php functions named so strangely? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
It sometimes feels like a drunk person wrote all the functions for php...Some are combined words with no underscore, other times functions are randomly underscored...Like using 'strtolower' and 'str_replace'...why does the former not have underscores (like str_to_lower) and the later does? and for that matter why is 'replace' the full word but 'str' isn't 'string'? If we are shortening words why not "str_rep"? Or better yet, why shorten anything and instead just make everything clear, obvious and readable, like "string_replace" and maybe consistently apply this to all functions in php? Is there some reason for why these functions are so strangely named? Is it just sloppy laziness in the language or do these apparent inconsistencies have some meaning?
Have a look at the history of PHP: http://en.wikipedia.org/wiki/PHP#History
It was developed organically by different people, what resulted in this inconsistent naming.

Do you advise against using text files instead of database? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
To make things short: I'm writing an anonymous forum software with PHP. I just feel like using a database is overkill and restrains my amateur skills. Do you advise against using text files instead of database?
Thanks.
A database has advantages like some sanitation (no breaking of delimiters, newlines etc.) and less danger of access conflicts when multiple instances try to read from the table - and different from a file-based approach, writing conflicts are constrained to the record in question only.
Recommendation: use database
To make things short: Yes. Strong advise against text files.

Require email registered to be from specific domain(s) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
All,
I'm curious what the best approach to this would be. In case the tags weren't noticed, I'm using PHP and Laravel 4.
My application requires that users register with an email address that is from specific domain names. Currently there is only one domain, however, I can see it being a requirement to white list others.
I would assume it would be best to put the domains into an array. Would I run a regex from $rules array against that array? I'm somewhat green to regex. I don't use it often enough to commit anything advanced to memory so feel free to talk to me like a 2 year old.
You can create a custom validator for this. See http://laravel.com/docs/validation#custom-validation-rules for reference.

Why is PHP inconsistent? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Though, a best kick-start development language; but I don't know why PHP lacks of consistency in naming functions etc? I've been developing for years, but most often I miss-spell function names and forget their parameter structures. Why isn't there any standard conventions followed in PHP for naming? Some times, it's like substr and sometimes str_replace? I often forget if needle should be first argument or second? or haystack be first or second? Is team behind PHP working on developing a consistent conventions and names?

Is the term "handle" reserved in PHP? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
In my php code, I am writing a class to create log files, and therefore have to work with files. I would like to store the variable $handle as a field, however when I refer to it as $this->handle, "handle" changes color, to indicate that perhaps it is a reserved term.
I looked through the php manual as well as some other online sources and haven't found anywhere saying it is actually reserved. Can someone clear this up for me?
Thanks for your help.
Cheers!
------------- Edit ---------------
It looks like it's recognizing handle as at least 3 static methods...still not sure what the "K" word means. Key?
Not only is it not reserved, but it is a common convention to call resource IDs and more $handle. In fact, you can find it throughout the PHP documentation. For example, fopen.

Categories