#"Discard" variable in php

3 messages · Page 1 of 1 (latest)

obsidian junco
#

In C# I can use a _ to "discard" a variable if I don't need it. Is there anything similar in PHP? I am currently using this but that doesn't really discard the variable for what I know

class PortalTenantInfoController extends Controller
{                                                      >>>VVV<<< 
    public function getTenantInfoBasic(\Request $request, $_, string $portalName)
    {

    }
}
#

in cases where I don't need the first param but I do need the second one from the route

sinful berry
#

Then just don't typehint it in that method.

class PortalTenantInfoController extends Controller
{                                                      
    public function getTenantInfoBasic(string $portalName)
    {

    }
}