The problem I’m facing is quite common I suppose but I didn’t see a single thread in internet.
If I use isset($_POST),
- Will it always return
true? - Does the response depend on the version of PHP I use?
- Is
$_POSTis a variable? (it’s a super global ‘variable’ after all). Because in php.net documentation, it is mentioned
isset() only works with variables as passing anything else will result in a parse error.
Yes, even if the page was opened using
GETmethod or nothing wasPOSTed.No it does not (not sure about very old versions of PHP).
Yes
This is explicitly mentioned in the manual so that people do not try to do cheaky stuff. These won’t work for example:
Now, why would you want to check if
$_POSTis set. Perhaps want to check if a certain variable (e.g. email) was posted, in that case you need to check: