Link to home
Start Free TrialLog in
Avatar of madstylex
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:

<?php

$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
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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