pdtest Posted March 12, 2009 Share Posted March 12, 2009 Am trying to pass the command to another check in the script. The Variable is passed from the URL. . My issus is that when the Variable is matched, then I pass the command "eregi" to the next check in the script and that works fine. Now if the same variable does not match, then I send the command "!eregi" to the next check and that fails. Any ideas how to pass !eregi to the command and why does it fail ? <? $ans = "ftp"; echo $_GET['bg'] ; echo "<br>"; if ( eregi( 'ftp', $_GET['bg'] )) { $cmd = "eregi" ; echo "$cmd"; echo "<br>"; } else { $cmd = "!eregi" ; echo "$cmd"; echo "<br>"; } if ($cmd('ftp', $ans)) <--This is not working when $cmd is !eregi { echo "matched"; } else { echo "not matched"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/149037-php-help-needed/ Share on other sites More sharing options...
samshel Posted March 12, 2009 Share Posted March 12, 2009 i m not sure why that doesnt work. but what u r doing can be achieved by the following code too.. <?php $ans = "ftp"; $operator = true; if ( eregi( 'ftp', $_GET['bg'] )) { $operator = true; echo "$operator"; echo "<br>"; } else { $operator = false; echo "$operator"; echo "<br>"; } if (eregi('ftp', $ans) == $operator) { echo "matched"; } else { echo "not matched"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/149037-php-help-needed/#findComment-782599 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.