gWorldz / get-simple-cms

Automatically exported from code.google.com/p/get-simple-cms
GNU General Public License v3.0
0 stars 0 forks source link

suggestion: make use of ternary operator #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was looking at the latest revision and saw the following:

if(isset($_POST['prettyurls'])) {
$PRETTYURLS = $_POST['prettyurls'];
}

I would recommend replacing single ifs like this with:

$PRETTYURLS = (isset($_POST['prettyurls'])) ? $_POST['prettyurls'] : false;

I think this may call for a little cleaning on how things are saved but its 
much cleaner way of setting if'd variable.

Original issue reported on code.google.com by talkingt...@gmail.com on 11 Nov 2010 at 9:57

GoogleCodeExporter commented 9 years ago
Will do, were already doing this on other files..

It was just a quick fix to test the latest build.

Mike

Original comment by MichaelS...@gmail.com on 11 Nov 2010 at 10:16

GoogleCodeExporter commented 9 years ago
just a thought... as there's no 'else', isn't this cleaner?

if(isset($_POST['prettyurls'])) $PRETTYURLS = $_POST['prettyurls'];

(one line, no curly brackets)

Original comment by carnav on 12 Nov 2010 at 7:03

GoogleCodeExporter commented 9 years ago
In this case, I think so but I think the way the config file is should be fixed 
to better provide a true and false value for each setting but I could be wrong 
just how I have always programmed.

Original comment by talkingt...@gmail.com on 12 Nov 2010 at 12:49

GoogleCodeExporter commented 9 years ago
I don't really have a preference... any of the three ways work. I think the 
first comment is cleaner, but yet a little more confusing to an outsider 
looking at the code. 

The one thing that I love about GetSimple is that anyone that knows a little 
bit of PHP can help us debug and suggest fixes. This is probably due a little 
to my unconventional coding nature and structure - but i keep the code very 
simple and easy to read. I would like to keep it that way in the future as well 
(even though we keep introducing more and more complex features)

Original comment by c...@3pcmedia.com on 12 Nov 2010 at 3:43

GoogleCodeExporter commented 9 years ago
the more i think about this, the more i feel this is just a preference in 
coding, and not really a bug or an enhancement. Now that we know about it - we 
can use it if the situation arises.

Original comment by ccagle8 on 31 Jan 2011 at 2:25