Jump to content

Is it possible to get $c . 35 together (For use as variable)


Mudsaf
 Share

Recommended Posts

Hello, now im trying to make this code working.

 $number =  rand(0, 5); if ($_GET['code'] == '$c' . $number) {echo "The code was correct.";} else {echo "The code was wrong";}

So the code below only pastes it as text so it doesn't really use the variable what comes example $c1.

echo '$c' . $number;

so i got variables like these.

$c1 = 12361 $c2 = 26323

and i wan it go check if get code == $c + number.

Link to comment
Share on other sites

single quote wont evaluate value. double quote will

if($_GET['code']=="{$c}{$number}")

Link to comment
Share on other sites

Like this or not
<?PHP//test filename.php?code=3$number =  rand(0, 5);$c='c';if ($_GET['code'] == $$c.$number){echo "The code was correct.";} else {echo "The code was wrong";}//echo '<br/>'.$$c.$number;?>

Tried to echo $$c.$number;Pasted following text c3
Link to comment
Share on other sites

sorry, i misunderstood the problem.try it

${"c$num"}

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...