Web服务

时间:2018-01-07 11:55:42

标签: android web-services web slim

我有那个网络服务

$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调用正确的echo,因为这样web服务就可以完成两个echo。我不想复制那个Web服务。

1 个答案:

答案 0 :(得分:0)

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

只需下载并加入网络服务文件

即可