on-internet
← Community

what does curly brackets {} do in a PHP string? [duplicate]

Stack Overflow ·

For example, check this following query; $query = "SELECT * FROM users WHERE user='{$_POST['username']}'; What's the use? In string contexts, I do understand the problem it solves. I can do stuff like $animal = "cat" echo "{$animal}s." // outputs cats but in the SQL I posted above, I just don't get it. Wouldn't the following be equally good? $query = "SELECT * FROM users WHERE user='$_POST['username']' AND password='$_POST['password']'"; So, Where does using the { and } get handy? Appreciate any example in SQL context?

Comments

Sign in or sign up to comment and upvote.

No comments yet.