I'm developing a small system to add records which be can opened later. On the page view.php it shows all records of all different country. I just extend this to only show one selected countries.
I call this function with the following argument:
$toxRecords->getStatsCountry();
If I want to show only one country, I just simple add the county code as parameter. Example:
$toxRecords->getStatsCountry('NL');
Because I use one page to show all countries but also one specific country it needs to check if there is an variable.
I check my POST with the following argument: toxInput::get('country');
This just simple return: $_POST['country']
.
Now I just want that it will only use the function parameter if value country exists. This can be very simple, see below:
if($country = toxInput::get('country')) {
$toxList = $toxRecords->getRecords($country);
} else {
$toxList = $toxRecords->getRecords();
}
But I was wondering if it possible to shorten this to one single lane? Example what I tried and will explain what I want:
$toxRecords->getRecords(if($country = toxInput::get('country')){ echo $country; });