<form method="post" action="/scheduler/run">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Controller</label>
<input type="text" class="form-control" name="form-controller" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Method</label>
<input type="text" class="form-control" name="form-method" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Seconds</label>
<input type="number" class="form-control" name="form-seconds" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Loops</label>
<input type="number" class="form-control" name="form-loops" />
</div>
</div>
</div>
</form>
我有这个form
数据用于调度,我想运行一个由controller
和method
组成的php
函数,seconds
是工作多少秒,loops
是工作多少次。
我的尝试:
<?php
class Scheduler extends CI_Controller {
public function run()
{
$form_data = $this->input->post();
for ($i=0;$i < $form_data['form-loops'];$i++) {
$form_data['form-controller'].'/'.$form_data['form-method']; //run the function
sleep($form_data['seconds']);
}
}
}
?>
试试这个:
<?php
class Scheduler extends CI_Controller {
public function run()
{
$form_data = $this->input->post();
for ($i=0;$i < $form_data['form-loops'];$i++) {
$method = $form_data['form-controller'].'/'.$form_data['form-method']; //run the function
$this->$method;
sleep($form_data['seconds']);
}
}
}
?>