We help IT Professionals succeed at work.
Get Started

php script to compare value from command line

madstylex
madstylex asked
on
473 Views
Last Modified: 2014-05-01
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
Comment
Watch Question
Fixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE