I pass parameters to a function in PHP. I dont know if the parameter is defined or not. Right now I check if the parameter is defined and cast to null if not before calling the function. Is there a more elegant way to do it by casting or something similar? I want the function default value to be used if the parameter is not defined.
Example:
//Params['x'] may or may not be defined
// I want to use this:
a(params['x']);
//Currently I use this (which I want to avoid) :
a( isset (params['x'])?params['x']:null);
function a (data=null){
// Here I want data to be null if params['x'] is not defined.
}