How do you require a parameter in user-defined functions?

For example you have a class of methods. You want to share your class with colleagues, so basically they would have to actually go back-and-forth to see what parameters were required. I tried using something like this:
[php]
class User{
public function __construct($Var){
if(isset($Var)){
die(“Required Var”);
}else {
return $Var;
}
}
}
[/php]

It threw an error. So how would you? It seems like a dumb question, but I’m curious to know. Anything would help.

Your example show how to create a function/method with a required param, its supposed to throw an error if you have invalid code.

What functionality is it you are missing?

Using the die keyword is old code style and should be replaced. If in a class you would throw an exception for the error.

Sponsor our Newsletter | Privacy Policy | Terms of Service