473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

need help about php variable

15 Byte
[PHP]<?php
if ($check!==$_SESSION["validate"]){echo 'Validation is not ok';}
else { echo 'OK';}
?>[/PHP]
the above doesn't work

but the below work
[PHP]<?php
if ($check==$_SESSION["validate"]){echo 'ok';}
else { echo 'validadation is not OK';}
?>[/PHP]


How the variables work logically with 'if' in PHP??? strange

The below also works

[PHP]if (strcmp($check,$_SESSION['validation'])==0){echo 'ok';} else {echo 'validation is not OK';}[/PHP]
Mar 24 '08 #1
2 979
ronverdonk
4,258 Expert 4TB
== means: value is equal: $a == $b Equal TRUE if $a is equal to $b.
=== means: value and data type must be equal: TRUE if $a is equal to $b, and they are of the same type.

See the php manual on comparison operators

Ronald
Mar 24 '08 #2
wesley1970
15 Byte
Thanks very much, actually, not because of it..

by using strcmp we don't need to trim the string, but i don't know why if i use ==, i have to trim it, by using the below, it works

[PHP]<?php
if (trim($check!)!==trim($_SESSION["validate"])){echo 'Validation is not ok';}
else { echo 'OK';}
?>[/PHP]
Mar 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fabien Penso | last post by:
Hi. I need a little help to optimize requests on a table, and I have no idea how to do it (I optimized already a lot other table, but this one is a pain). My table looks like : CREATE TABLE...
2
by: Fabien Penso | last post by:
Hi. I need a little help to optimize requests on a table, and I have no idea how to do it (I optimized already a lot other table, but this one is a pain). My table looks like : CREATE TABLE...
3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
2
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space...
15
by: Jess | last post by:
Hello, Sometimes declarations are all what we need when we define/declare classes (or functions?), but sometimes we need definitions. I learned that if we define a class (B) that has an object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.