Link to home
Start Free TrialLog in
Avatar of madstylex

asked on

php script to compare value from command line

Hi Experts,

I am writing a small php script in linux mint which is used to take an argument from the command line, compare it and confirm if it says "keyword" or not.  I am quite new to php, so it is probably something extremely simple.  I have also echoed $argv[1] in order to confirm that the script is in fact receiving the argument.

So far I have the following:


$test1 = $argv[1];

if (!$test1 == "keyword") {
        echo "you have typed in KEYWORD";
} else {
        echo "you have NOT typed in KEYWORD";

echo $test1;


Open in new window

As this code currently stands, every single output is "you have NOT typed in KEYWORD" regardless of what I type in.

Thanks in advance
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial