Jump to content

[SOLVED] Im stumped. If statement condition


jug

Recommended Posts

Hi,

 

I have got a variable called $string. It holds a string value that is dynamically created on the form requirements. For this example lets just say it holds 'username == test && password == test' as a string.

 

What i want to do is being able to test to see if the $string variable string value returns true not the variable itself as that will always return true as it will always be set containing at least some content. So..

 

  $string = 'username == test && password == test';

 

  if($string){  //test for variable string content not to see if $string has been set

 

  }

 

I hope i have made this clear enough and one of you guys out there will be able to help.

 

Thanks in advance

 

jug

 

 

 

 

Thanks for your reply. No that is not what i want as isset() just checks to see if the variable is set and in this case it will always be set as there will always be something in the string variable.

 

What i need is to test the $string content as a string (almost like echo-ing it in to the if statement itself).

Hey, my first post on phpfreaks.com  ;D

 

I think what you're searching for is:

 

$username = 'tedst';
$password = 'test';
$string = ($username == 'test' && $password == 'test');

  if($string == true){  //test for variable string content not to see if $string has been set
echo ('true');
  } else {
  	echo ('false');
  }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.