Jump to content

varible using if statement


CanMan2004

Recommended Posts

Hi

I want to change my varible, the current code I use is

[code]$name = "Dave Lawson";
print $name;[/code]

I want to put a if statment into the above, the if statement I want to use looks like

[code]if ($hisname >= '1') { print " and "; } else { print "s"; };[/code]

I tried to do

[code]$name = "Dave Lawson" if ($hisname >= '1') { print 's and '; } else { print 's'; };
print $name;[/code]

But that brought nothing but errors.

Can anyone help?

Thanks in advance

Dave
Link to comment
https://forums.phpfreaks.com/topic/21148-varible-using-if-statement/
Share on other sites

If $hisname is not defined then it won't even do that.

Wild guess here but I think you are tryign to differentiate between one name or more and add and if its more than one....

If that is the case then you would have to explode $name and count the number of elements - but then someone might put a middle name in.

have a little think and come back with what you are trying to detect and maybe we can help a bit more.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.