mysql - A kind of actions handler on my PHP project? -
i wanted actions handler. don't know how should like. started create that:
mysql:
create table `handlers` ( `name` varchar(65) not null default '', `key` varchar(65) not null default '', `handler` varchar(65) not null default '' ) type=myisam ; php:
if(isset($_get['action']){ $action = $_get['action']; $sql = "select * handlers key = '.$action.'"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_array($result); // , here problem... } the problem is, don't know how should execute string function in php?
for illustration if string in handler test, code should execute function test();. thinking eval(); don't have thought how it.
i'm not sure i'd in real project, can create work way describe so:
$handler = $row['handler']; if (function_exists ($handler)) { $handler (); } php mysql
No comments:
Post a Comment