Hey!

I'm making a tiny application, and I'm using post-data. And the PHP 5.3 throws warnings if i don't check if a $_POST variable is set before trying eg. $var = $_POST['somevariable'];

And what I wanted to do is making as small code as possible, but still check if the post-var is set or not, and if one of the post-vars is not set, it should set a $error variable to true.

So I wrote the code like this.

PHP Code:
$error false;

$userid = isset($_POST['userid']) ? $_POST['userid'] : $error true 43;

if(
$error == true) echo "error\n"
What happens is that, if $_POST['userid'] is set then $userid should get it's value. But if its not, $userid should get the value 43, and the $error variable should be set to true. And it sure works. But I don't really get what happens there. I just tried the $error = true | 43 by a coincidence, and it works, but I'm not sure if it's really the right way of doing it? Is this really correct syntax?

And if it is good syntax... Is it any way of making this even shorter? for example so I don't have to write $_POST['userid'] two times? So I could replace it with $1 or something like that.

Cheers,
Artheus