$url = to_asset('img/logo.png');
$url = to_asset('js/main.js', 'scripts/');In this example, the `to_asset` function is being used to generate the URL for the `main.js` JavaScript file located in the `scripts/` directory. The second parameter is used to specify the base directory where the asset is located, which can be different from the default directory. The `to_asset` function is a part of several PHP frameworks and libraries, including Laravel, Symfony, and Yii. However, it is also possible to implement the function in a custom PHP script or application.