Jump to content

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

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.