duandu5846 2012-12-04 17:23
浏览 13

在PHP中比较胡子生成的字符串

If i compare a mustache generated variable with the actual string it shows weird result.

<?php
$username = {{userName}};
echo $username; // john

 //if i compare with the string it returns false
if ($username == 'john') //return false

//if i print strlen($username) it returns 14 but it should return 4

?> 

how to convert it to regular string so i can compare it with other string in php? any help?

  • 写回答

3条回答 默认 最新

  • douxian4376 2012-12-04 17:28
    关注

    Wrap it in to trim http://php.net/manual/en/function.trim.php

    It looks like mustache adds some whitespace.

    评论

报告相同问题?