stlbelieve Posted July 30, 2008 Share Posted July 30, 2008 in php 5, i have.... $my_variablle_results = shell_exec("call my java program"); and the java program does either: System.out.println("SUCCESS"); or System.out.println("FAILURE"); it works fine, and if I echo $my_variable_results, i see "SUCCESS" and "FAILURE" like one would expect. But, if i then do (in php) if($my_variable_results == "SUCCESS") // with single or double quotes... { echo "it is a success";} else { echo "no success"; } "no success" get's printed, even when the echo of $my_variable_results is SUCCESS Is there something with the format or datatype that could cause this comparison to fail? i tried declaring declaring it first like: $my_variable_results = 'test'; before calling the java program... didn't help. i am using java 1.4.2 which is pretty old, but i doubt that would be problematic. any ideas? thanks, mike. Link to comment https://forums.phpfreaks.com/topic/117394-java-php-variable-question/ Share on other sites More sharing options...
.josh Posted July 30, 2008 Share Posted July 30, 2008 well i see in your $my_variablle_results = shell_exec("call my java program"); you have an extra l in variable is that a typo you made here or is that in your code? Link to comment https://forums.phpfreaks.com/topic/117394-java-php-variable-question/#findComment-603871 Share on other sites More sharing options...
rhodesa Posted July 30, 2008 Share Posted July 30, 2008 my guess is there is a new line character at the end. try wrapping the returned output with trim() if(trim($my_variable_results) == "SUCCESS") Link to comment https://forums.phpfreaks.com/topic/117394-java-php-variable-question/#findComment-603875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.