I have a weird problem. I have checking a php string like this:
On Page1
$_SESSION['test']=<a value from a row fetched from db>
On Page2
$myVar=$_SESSION['test'];
echo $myVar;
if($myVar=="This is the match string"){
echo "Matched";
}else{
echo "Not Matched";
}
I can see that $myVar echoed out the same string that I am checking again “This is the match string” but it still goes into else. I tried:
$myVar=(string)trim($_SESSION['test']);
but it still goes into else. What can be the issue? Any idea?
It’s possible there are trailing blank spaces (space,tab, newline).
Try
Doing var_dump( $_SESSION[‘test’] ); might also reveal the problem.