mardi 22 janvier 2019

How to execute a variable function that has a default input

I have a scheduler something like

$schedule->command('foo')
          ->weekdays()
          ->hourly()
          ->timezone('America/Chicago')
          ->between('8:00', '17:00');

I would like to store ->between('8:00', '17:00'); in my database so that I can always change it. Later on for example I can use rather ->at('02:00') ( just example ).

I know that with PHP7 we can use variable functions better than every something like

http://php.net/manual/en/functions.variable-functions.php

<?php

function sound_dog()() { return 'woof'; }
function sound_cow()() { return 'moo'; }

$animal = 'cow';
print ('sound_' . $animal)();

But when I want to have an default input inside ('anything at all') it doesn't work. All examples assumes that there is no default input.

How can I make a variable function that has input inside itself?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire