0

Lets take this code as an example:

class foo
{
    private $segments = NULL;
}

$segments will be an array later.

The question:

Should i tell PHP that $segments is an array (private $segments = array(); ) or leave it as NULL?

What is better?

Thank you!

1 Answer 1

1

if you are sure it will be an array later, declare it as an array, if it may change during the program, just keep it as it is.

PHP is non-typed language, so it doesn't really matter, it just a matter of standards and habits.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.