Help (noob)

Status
Not open for further replies.

Stallone

[◣_◢]
Feb 4, 2012
419
128
PHP:
<?php
$name = 'Rivaz';
$age = '13';
if (strtolower($name)==='Rivaz')    {
    if ($age>13) {
    echo 'You\'re over 13.';
    if (1===1) {
    echo 'Yes, 1 is equal to 1!';
}
}
} else {
  echo 'You\'re not Rivaz';
}
?>
Basically - it's saying "You're not Rivaz", where I have set it as Rivaz. D:
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
You're casting $name to lowercase in line 4, but then comparing it against a string that is not lowercase.

PHP:
<?php
$name = 'Rivaz';
$age = 13;
if (strtolower($name) === 'Rivaz') {
    if ($age > 13) {
        echo 'You\'re over 13.';
    }
    if (1===1) {
        echo 'Yes, 1 is equal to 1!';
    }
} else {
    echo 'You are not Rivaz.';
}
?>
...should do.
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
For starters, strtotower makes it so Rivaz becomes rivaz... So obviously these are not the same.
Second, $age = 13 .... if($age>13) will return false, 13 is not larger than 13.
 

Stallone

[◣_◢]
Feb 4, 2012
419
128
Thank you guys, I'm a noob. :/

Anyways, after all the help thread closed please.
Don't delete it, I can refer to it at times for help.:)
 
Status
Not open for further replies.

Users who are viewing this thread

Top