Help plz

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hilal6
Forum Newbie
Posts: 6
Joined: Fri Jun 26, 2015 1:15 pm

Help plz

Post by hilal6 »

Greatings everyone AOA.

I need help with the following code

Code: Select all

<?php
$a=50;
$b=55;

if(!$a>$b)
{
	echo "b is greater than a";
}
elseif(!$b>$a){
	echo "a is greater than b";
}
else
{
	echo "a=b";	
}
?>
Why does it echo a=b and not b is greater than a?
Last edited by hilal6 on Fri Jun 26, 2015 1:45 pm, edited 1 time in total.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help plz

Post by Celauran »

Because !$a == false and false > $b == false.
hilal6
Forum Newbie
Posts: 6
Joined: Fri Jun 26, 2015 1:15 pm

Re: Help plz

Post by hilal6 »

so your saying that !$a means not $a? Meaning that it doesn't even consider the variable ? Right?
hilal6
Forum Newbie
Posts: 6
Joined: Fri Jun 26, 2015 1:15 pm

Re: Help plz

Post by hilal6 »

In this piece of code

<?php

$q="0";
if(empty($q)&&!is_numeric($q)){

echo "please enter a value";
}
?>

the reason it doesnt echo is because it converts the string to a numeric value. Right ?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help plz

Post by Celauran »

!$a>$b == false
!($a > $b) == true
Post Reply