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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.