0

I was wondering why i can not compare a string that I pass through request.HTTPBody = post.String.dataUsingEncoding(NSUTF8StringEncoding) to the php server to a string of type variable. I pass a String through request.HTTPMethod = "POST" and I want to find out whether the passed string equals to a value, for example:

$item=$_POST[item]
if ($item == "Car') echo "Automobile";

The code doesn't work unless I change it to this(not double equal sign):

$item=$_POST[item]
if ($item = "Car') echo "Automobile";

Any help would be appreciated!

Luke
  • 407
  • 2
  • 10
  • 22
  • A few problems here. Your quotes are miss-matched around Car. Assuming typo in this question as this is broken code. You need quotes around item when you access it in the array. `$_POST['item']`. As is, it will throw an error but still work. Your second example is invalid as you're comparing the boolean result of an assignment which will always be the boolean value of the value assigned. Boolean of "Car" is `true`. You should `var_dump()` $_POST['item'] and see what the value is – phil-lavin Nov 22 '16 at 23:21
  • What does this have to do with Swift? Nothing. Your question is about comparing strings in PHP. – Eric Aya Nov 23 '16 at 07:36

0 Answers0