jug Posted March 2, 2009 Share Posted March 2, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147497-solved-im-stumped-if-statement-condition/ Share on other sites More sharing options...
br0ken Posted March 2, 2009 Share Posted March 2, 2009 Is this what you want? http://uk.php.net/isset Quote Link to comment https://forums.phpfreaks.com/topic/147497-solved-im-stumped-if-statement-condition/#findComment-774291 Share on other sites More sharing options...
jug Posted March 2, 2009 Author Share Posted March 2, 2009 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). Quote Link to comment https://forums.phpfreaks.com/topic/147497-solved-im-stumped-if-statement-condition/#findComment-774551 Share on other sites More sharing options...
phant0m Posted March 2, 2009 Share Posted March 2, 2009 well... there is eval... http://ch2.php.net/manual/en/function.eval.php But I can't recommend using that, as it is a major security issue Quote Link to comment https://forums.phpfreaks.com/topic/147497-solved-im-stumped-if-statement-condition/#findComment-774553 Share on other sites More sharing options...
MadTechie Posted March 2, 2009 Share Posted March 2, 2009 Yep sounds like you need eval(), or a new design.. as from your concept your going to have major security problems what are you using it for ? Quote Link to comment https://forums.phpfreaks.com/topic/147497-solved-im-stumped-if-statement-condition/#findComment-774560 Share on other sites More sharing options...
sandstorm140 Posted March 2, 2009 Share Posted March 2, 2009 Hey, my first post on phpfreaks.com 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'); } Quote Link to comment https://forums.phpfreaks.com/topic/147497-solved-im-stumped-if-statement-condition/#findComment-774563 Share on other sites More sharing options...
jug Posted March 2, 2009 Author Share Posted March 2, 2009 Yeh sandstorm140 thats what i was after but i think a code redesign is needed first. Thanks all jug Quote Link to comment https://forums.phpfreaks.com/topic/147497-solved-im-stumped-if-statement-condition/#findComment-774605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.