Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tzak9022's avatar

PHP Basics

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?

0 likes
13 replies
tykus's avatar

when to use parenthesis, brackets, again parenthesis inside brackets and vice versa

Code example?

tzak9022's avatar

@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's avatar

@tzak9022 @tzak9022 that is because the whereBetween method takes an array as it’s second argument. Check the Laravel API for details, or use an IDE with intellisense

tzak9022's avatar

@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 ..

thinkverse's avatar

@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.

1 like
tykus's avatar

@tzak9022 the PSR standards include code styling rules, you can get a good IDE to automatically apply these rules

1 like
kokoshneta's avatar

@tzak9022 Do you mean syntax? That’s what you’re essentially talking about. Brackets and parentheses are part of the syntax of PHP.

borth's avatar

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.

1 like
borth's avatar

I forgot to mention Laracasts 🤦

Please or to participate in this conversation.