when to use parenthesis, brackets, again parenthesis inside brackets and vice versa
Code example?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello guys, I would like to know if you have a good reference to learn the very basics of PHP for example, when to use parenthesis, brackets, again parenthesis inside brackets and vice versa?
when to use parenthesis, brackets, again parenthesis inside brackets and vice versa
Code example?
@tykus for example check this code
->whereBetween('arrivaldate', [$from, $to])->get();
why did we put $from inside brackets why not parenthesis? who decided that it must be inside brackets?
@tykus there is a specific word that tells you the rules you need to respect when you writr a php code like how many spaces you have to make between each statement, space between the lines etc... what do we call this, I really i just forgot it, it's like Standards ..
@tzak9022 because the second parameter expects an array and [] is an array in PHP. So the function whereBetween has a signature of approx.
function whereBetween(string $column, array $between)
Where the array contains the min and max values, or the values we want to see if we're are between. That's a design decision the Laravel team made a long way back. It could've been designed to accept more parameters, but it wasn't.
And those design decisions have nothing to do with PHP itself really. Well, the syntax does I guess. But what functions are named in Laravel and what those accept and don't accept have no bearing on PHP.
To learn the syntax of PHP I'd recommend browsing the language reference, and to learn what methods and such Laravel has, look at their documentation.
@tzak9022 the PSR standards include code styling rules, you can get a good IDE to automatically apply these rules
@tzak9022 Do you mean syntax? That’s what you’re essentially talking about. Brackets and parentheses are part of the syntax of PHP.
A great place to start is php.net https://www.php.net/
If you like video content, check out Udemy or other similar services. There are a lot of instructors teaching basic PHP. There is also a lot of content on YouTube, but the quality and accuracy can vary.
I forgot to mention Laracasts 🤦
There are some on youtube.
@tzak9022 Try this Laracasts series: https://laracasts.com/series/php-for-beginners
@JeffreyWay OMG I got a reply from Jeffrey Way, Thanks alot Sir.
Sure will do.
Explore https://onramp.dev/en and https://phptherightway.com/
Please or to participate in this conversation.