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
PHPLinuxScripting Languages

Avatar of undefined
Last Comment
Dave Baldwin

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dave Baldwin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23