Skip to content

Instantly share code, notes, and snippets.

@datashaman
Last active September 16, 2024 15:08
Show Gist options
  • Save datashaman/2698e9d471b3fe82f2c1b5f576e94ede to your computer and use it in GitHub Desktop.
Save datashaman/2698e9d471b3fe82f2c1b5f576e94ede to your computer and use it in GitHub Desktop.
<?php
return [
'add' => fn ($a, $b) => $a + $b,
];
<?php
['add' => $add] = include('calc.php');
echo $add(2, 3);
@datashaman
Copy link
Author

php main.php

The use of an array is not ideal, but it allows for selection of functions using object destructuring assignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment