Recently, I've attempted to be tricky and assign a variable inside of an isset function. I tried to do it like so
if(isset($accountid =$_POST['Recipient']))
{
// my code here ...
}
However, when I do this I receive the error
syntax error, unexpected '=', expecting ',' or ')'
Here is the documentation for isset if you want to reference it in your answer.
bool isset ( mixed $var [, mixed $... ] )
This isn't the hugest deal - but I'd be interested to know why I can't do something along those lines!
You can also use ! empty() in place of isset() the function ! empty() works for both isset() and check whether the value of any string is not null, 0 or any empty string.
Code explained isset( $_POST['submit'] ) : This line checks if the form is submitted using the isset() function, but works only if the form input type submit has a name attribute (name=”submit”).
PHP isset() Function The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL. This function returns true if the variable exists and is not NULL, otherwise it returns false.
The isset() function is an inbuilt function in PHP which checks whether a variable is set and is not NULL. This function also checks if a declared variable, array or array key has null value, if it does, isset() returns false, it returns true in all other possible cases.
isset
is a language construct and not a true function. It is mentioned in the docs:
Warning
isset() only works with variables as passing anything else will result in a parse error. For checking if constants are set use the defined() function.
You are trying to pass a statement, this might be the reason. Here is a note I found in php.net manual for isset().
http://php.net/manual/en/function.isset.php
isset() only works with variables as passing anything else will result in a parse error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With