Home >Backend Development >PHP Tutorial >插入js效果但是不出效果,我用{$user_name}判断的,是不能混着用么

插入js效果但是不出效果,我用{$user_name}判断的,是不能混着用么

WBOY
WBOYOriginal
2016-06-23 13:52:591051browse

登录人为:{$user_name}
<script></script>
<script> <br /> $(document).ready(function(){ <br /> if({$user_name} !=null) <br /> {$("#login_null").hide();} <br /> } <br /> }); <br /> </script>

去掉if  效果就出来了 但是加上判断就不行。。上面我也打印了判断条件,也显示了 ,但是不能判断是因为神马


回复讨论(解决方案)

if({$user_name} !=null) 是错误的!变量未定义
if("{$user_name}" !=null) 要用引号括起来!

谢倒不必,这是常识
一个字母数字的组合
有引号括起时称作字符串
没有引号括起时称作变量
不能弄混淆了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn