Jump to content

Will this work?


Aureole

Recommended Posts

Will it work if I change this:

<?php
if($friendCount == 0)
{
	$friendText = 'My Friends';
}
else
{
	$friendText = ($friendCount == 1) ? '1 Friend Online' : $friendCount.' Friends Online';
}
?>

 

...into this:

 

<?php
$friendText = ($friendCount == 0) ? 'My Friends' : ($friendCount == 1) ? '1 Friend Online' : $friendCount.' Friends Online';
?>

Link to comment
https://forums.phpfreaks.com/topic/86752-will-this-work/
Share on other sites

If I nested any more than 2 then it becomes harder to read (if it is possible to nest them), but it does make my file shorter and I assume it doesn't take PHP LONGER to go through this... plus with portions of code like this which I know are never going to change even as I continue to develop whatever I may be developing - it doesn't really matter how readable it is as far as I'm concerned.

 

 

Link to comment
https://forums.phpfreaks.com/topic/86752-will-this-work/#findComment-443410
Share on other sites

I tested it and while I received no errors, something didn't seem to be working right. It would show me as having 1 New Message and 1 Friend Online even though that isn't true. Could you just let me know if it should work as I have tried it like you said and I just don't know.

Link to comment
https://forums.phpfreaks.com/topic/86752-will-this-work/#findComment-443413
Share on other sites

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.