The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
(no spaces in line)
Basically is an if..then..else statement.
Can anyone point me to documentation on this form of writing PHP code? It seems damn complicated for little benefit (especially in regards to future code readability),
I.e. a nested line is: -
($temp[$n]==NULL)? (is_array($err))? array_push($err,$varList[$n]): $err=array($varList[$n]):NULL;
from
if($temp[$n] == NULL)
if (is_array($err)) array_push($err,$varList[$n]);
else $err=array($varList[$n]);
So. Is it worth it in the end?
(no spaces in line)
Basically is an if..then..else statement.
Can anyone point me to documentation on this form of writing PHP code? It seems damn complicated for little benefit (especially in regards to future code readability),
I.e. a nested line is: -
($temp[$n]==NULL)? (is_array($err))? array_push($err,$varList[$n]): $err=array($varList[$n]):NULL;
from
if($temp[$n] == NULL)
if (is_array($err)) array_push($err,$varList[$n]);
else $err=array($varList[$n]);
So. Is it worth it in the end?
One thing I love about PHP is that there are loads of different methods of doing things and you can develop your own style.
> Dunno, depends how easy you want to be able to look down the code I
> suppose.
Aye, I like the style of the one line code, but it's unneccesarily cluttered. In a development environment where you may have to go back in the future, readability is key.
Hmmmm.
> Exactly - and not just for you either, someone else might have to look
> at the code and go "wtf!?". Best to keep it standardised in
> that case.
True. I'm going to leave it in, but remmed out. That'll impress.
> Tried [URL]http://php.net[/URL] for more information?
Of course, but I don't know how to phrase it. "?" and ":" aren't really the best search terms, and the rest is my specific code. :D
> Of course, but I don't know how to phrase it. "?" and
> ":" aren't really the best search terms, and the rest is my
> specific code. :D
Its just a shortcut for a control structure, I dont think its documented in the manual though. Try looking up control structures in the language syntax.
(expr) ? (true) : (false) is actually from C anyway (I dont know if that was the first place it turned up). And PHP supports alot of C shortcuts.
No real benefit to using it, bit faster code, but not something you'd notice.
> (expr) ? (true) : (false) is actually from C anyway (I dont know if
> that was the first place it turned up). And PHP supports alot of C
> shortcuts.
>
> No real benefit to using it, bit faster code, but not something you'd
> notice.
*slap* Knew I'd seen it somewhere before. That'll be where. Cheers.
Tenary operator http://www.php.net/operators.comparison