网络服务

Web service for web

我有那个网络服务

$app->get('/students', function(){
require_once('db/config.php');
foreach ($db->students()
             ->order("name")
         as $row){
    $data[]=$row;
}


echo  json_encode($data, JSON_UNESCAPED_UNICODE); //for android

$loader = new Twig_Loader_Filesystem('views/students/'); //for web

$twig = new Twig_Environment($loader, array()); //for web

$template = $twig->loadTemplate('singup.php'); //for web

echo $template->render(array('data' => $data)); //for web
});

有人知道我怎样才能为 android 和 Web 调用正确的回显,因为 Web 服务通过这种方式执行两个回显。我不想复制该 Web 服务。

这对我的问题有效 http://mobiledetect.net/

只需下载并包含在 Web 服务文件中