Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.