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"; } ?> 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/149037-php-help-needed/#findComment-782599 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.