我已经mustache php在我的项目中设置了.
echo $template->render(array(
'data'=>$data,
'lang'=>$lang,
'getMaritialStatus' => function($text, Mustache_LambdaHelper $helper) {
return Common::getTextInHindi(ucwords(strtolower($helper->render($text))));
}
));
Run Code Online (Sandbox Code Playgroud)
我的用户定义的功能是
public static function getTextInHindi($maritialStatus) {
return $GLOBALS['lang'][$maritialStatus];
}
Run Code Online (Sandbox Code Playgroud)
现在在我的用户定义函数中,我在上面尝试打印时可以看到
print_r($GLOBALS['lang']['Married']); //gives correct output
print_r($GLOBALS['lang'][$maritialStatus]); //gives undefined index error
Run Code Online (Sandbox Code Playgroud)
即使$maritialStatus包含字符串'Married'.
为什么会这样呢?
我想知道如何在两列组合的表中找到重复值。
假设我的表有字段 id || name || father_name || region || dob
现在我如何找到结果集,例如:
.ie 我想找到三列相同的所有行。
我有一个基于react + node的项目,我在dist/目录中构建所有基于反应的组件,然后将此目录上传到服务器并通过nodeJS express.static()方法提供.
server.use(express.static(__ dirname +'/ dist'))
我还编写了一个节点中间件,它捕获每个请求并检查auth令牌是否传递给它.
users.use(function(req, res, next) {
const token = req.headers.authorization
if (token) {
jwt.verify(token, process.env.SECRET_KEY, function(err) {
if (err) {
res.status(400).json({message : err})
} else {
next();
}
});
} else {
res.status(400).json({message : 'Please send a token'})
}
})
Run Code Online (Sandbox Code Playgroud)
但是现在我面临的问题是,当我运行URL时http://localhost:3001/dashboard,节点中间件也会捕获它并检查令牌而不是渲染我的webview.
如何在nodeJS中区分webview请求和其他服务器请求