GetDotted Domains

Viewing Thread:
"Quicky Php question"

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.

Thu 26/05/05 at 10:37
Regular
"Lisan al-Gaib"
Posts: 7,093
(isset($HTTP_GET_VARS[$varList[$n]]))? $temp[$n]=$HTTP_GET_VARS[$varList[$n]]: $temp[$n]=NULL;

(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?
Thu 26/05/05 at 16:38
Regular
"Devil in disguise"
Posts: 3,151
Here it is
Tenary operator http://www.php.net/operators.comparison
Thu 26/05/05 at 16:32
Regular
"Lisan al-Gaib"
Posts: 7,093
Garin wrote:
> (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.
Thu 26/05/05 at 16:27
Regular
"Devil in disguise"
Posts: 3,151
Pandaemonium wrote:
> 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.
Thu 26/05/05 at 15:55
Regular
"Lisan al-Gaib"
Posts: 7,093
Freeola wrote:
> 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
Thu 26/05/05 at 14:18
Regular
Posts: 78
Tried [URL]http://php.net[/URL] for more information?
Thu 26/05/05 at 10:49
Regular
"Lisan al-Gaib"
Posts: 7,093
monkey_man wrote:
> 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.
Thu 26/05/05 at 10:48
Regular
"Pouch Ape"
Posts: 14,499
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.
Thu 26/05/05 at 10:46
Regular
"Lisan al-Gaib"
Posts: 7,093
monkey_man wrote:
> 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.
Thu 26/05/05 at 10:41
Regular
"Pouch Ape"
Posts: 14,499
Dunno, depends how easy you want to be able to look down the code I suppose.

One thing I love about PHP is that there are loads of different methods of doing things and you can develop your own style.
Thu 26/05/05 at 10:37
Regular
"Lisan al-Gaib"
Posts: 7,093
(isset($HTTP_GET_VARS[$varList[$n]]))? $temp[$n]=$HTTP_GET_VARS[$varList[$n]]: $temp[$n]=NULL;

(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?

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

10/10
Over the years I've become very jaded after many bad experiences with customer services, you have bucked the trend. Polite and efficient from the Freeola team, well done to all involved.
Very pleased
Very pleased with the help given by your staff. They explained technical details in an easy way and were patient when providing information to a non expert like me.

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.