maybe this is easy for most. But sometimes in a piece of code i see something like this:
public function myFunction(Class_Name $var){
//some nice code here
}
My question is, those paramaters what do they do and why do i want to use it? :)
The Class_Name portion is a type hint. The $var parameter must be an instance of that class (whether a new Class_Name() or an instance of any class that derives from it). You use it if you expect $var to be a certain kind of object, and not just any arbitrary PHP value. Type hints only exist natively for class/interface types and arrays, though.
A parameter is used for whatever you (or someone else) use it within the function/method.
public function myFunction(Class_Name $var){
//some nice code here
echo $var->someProperty;
}
If you are asking, whats Class_Name about: That's a type-hint. It means, that php will emit an error everytime you try to set anything else than an object of class Class_Name (or of an child class) as agument.
That's called typehinting and it assures that the $var variable is an instance of either Class_Name, or a class that extends Class_Name. It's just an assertion, really.