Link to home
Start Free TrialLog in
Avatar of Janith Ariyathilake
Janith AriyathilakeFlag for Sri Lanka

asked on

what is the error of below php code and how we can correct it? <?php $y = "&&"; if (&& == $y) { echo "variablenamed $y value is &&"; } ?>

hi,

what is the error of below php code and how we can correct it?


<?php

 

$y = "&&";


if (&& == $y) {

    echo "variablenamed $y  value is &&";

}

?>  

ASKER CERTIFIED SOLUTION
Avatar of Dr. Klahn
Dr. Klahn

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
Avatar of Janith Ariyathilake

ASKER

I want to assign "&&" to a variable as shown in above code and compare it. It can be using if statement or some other way.
Could you please correct that above mentioned code using proper way?    
SOLUTION
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
SOLUTION
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
I used "strcmp" function as,

<?php
$value= &&;
$pattern = &&;

if ((strcmp($value,$pattern)==0))
echo "captured ok";
?>

Then got error =>  Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in C:\xampp\htdocs\test3.php on line 2