« first day    last day (4948 days later) » 

10:03 PM
Thanks, Google doesn't allow for symbol searches!
 
no problem
-> is used when working with classes
 
Ok, and ? and :, I know it is some kind of short hand but how does it work in he following line -

echo fmod($1,2) ? 'even' : 'odd'

Is it effectively saying echo even or odd depending on the result of fmod?
 
It's just a shortcut for if/else.
@James Did you see that link I posted? :-)
 
indeed, it's a way of sneaking if statements in to crazy places. I personally don't like using it at all as far as readability goes
 
@Alexio The 5.3 version is useful.
 
10:13 PM
oh? do elaborate?
 
Yes, instead of going if (empty($foo)) { $foo = "default"; }, I can just do $foo = $foo ?: "default";
Which is clear and not sneaky, as long as you use it appropriately.
 
hmm, I don't quite understand yet...
how does that compare $foo to being empty?
or emptying foo....
 
Thanks for the link, I did not notice it but will take a look.

With the code I post above however I don't get how it decides whether to echo 'even' or 'odd'. fmod() will only return an integer correct? So how does it interpret from that integer which result to echo?
 
@Alexio Okay, if $foo is empty, it evaluates to false in the context of a conditional.
 
oh, ok, now I see
 
10:18 PM
@James That link will probably have information on how PHP type-coercion works.
 
I'm not sure it's necessarily easier
 
Well, define "easy".
 
having the ? symbol after what is being compared doesn't follow my English grammar
rather than reading in my head "if this then"....
 
@James The link I gave you is an introduction to the PHP language. Since you're unfamiliar with some basic language-level concepts, you'd be much better served by simply reading it, as opposed to answering one-off questions all night, and waiting for answers. :-)
s/answering/asking/
@Alexio The question mark comes after the second $foo, which is where the evaluation is taking place.
 
@Alexio Are you confused by the "(conditional) ? (if block) : (else block)" notation?
 
10:22 PM
@NateAbele not confused be it, but it takes marginally more time for my brain to parse what's going on
 
The more you see it the easier it is to understand, but I can definitely see what you mean.
 
Possibly because you're simply not used to it?
 
yes, quite possibly
 
It serves two good purposes, though, even though it can cause confusion when you don't see it much.
First, it allows for fewer lines of PHP. PHP has to be interpreted, so the fewer lines the better.
 
I've started maintaining code that uses it all the time, so I am only now finally becoming familiar with it
 
10:23 PM
This is especially nice when you're doing something simple like setting a value. Rather than if($condition){$val = 1;} else {$val = 2;} (which is a mouthful), you can use the much smaller $val = $condition ? 1 : 2;
 
@steven_desu That was actually not true until recently.
 
yes, with setting a value or echoing a value in a large block of HTML, it's very nice
 
The second advantage is that since it takes up fewer lines of code (and less space) it makes it easier to scan through very long projects. It condenses simple concepts into a single line rather than spanning them across several.
 
although, you can just have if ($something) {$foo = "bar";} else {$foo = "bar";} on one line as well?
 
That's considered bad practice.
 
10:25 PM
I'm aware
 
You can have that on one line, true. It still takes longer for PHP to interpret, though.
Plus, as was stated, it's bad practice to have a brace and not start a new line.
 
because there could potentially be further if else blocks?
 
Not just that, but it allows for more readability if you use line-breaks and tabs correctly.
 
Strictly speaking, there's no direct correlation between the space a statement takes up, and the amount of time the PHP interpreter spends on it.
 
Technically everything could be on one line XD
 
10:27 PM
Prior to 5.3, ternary operators were actually slower than if/else blocks, because of the way that the interpreter optimized if/else blocks.
 
oh, really? I'm just going to check the version of php is installed on my server
 
@Alexio Whether you're using new 5.3 features or syntax, you should definitely install it. You'll get an average 15-20% speed increase for free.
 
well, it depends on what centOS feels like doing upstream
 
/me gags.
 
haha, sorry
 
10:29 PM
Heh, yeah... locked-down OS distros are seriously one of the worst ideas ever.
 
Huh. I never knew pre-5.3 screwed up the ternary operators XD
I kinda want to look into that now
 
not my idea or my problem
 
If you care at all about your app's platform, you can't use a distro.
@steven_desu It didn't screw it up, it just wasn't optimized.
 
meh, it's PHP 5.1.6
I was only hired as a programmer. It's a shame they make me look after the server stuff as well because I normally just don't care about it. As long as it works ya know?
 
Which is buggy and ridden with security vulnerabilities.
 
10:35 PM
well... you say that
 
Yeah, I wouldn't consider that "working".
 
redhat and centOS often fix the more serious bugs (but the fixes in rather) but don't change the version number
put*
they manage their packages very strangely
I remember when I first took control of the server I tried installing a very recent package of PHP and everything broke
 
Wow.
Wait, like, their PHP stuff broke, or system-level stuff?
 
erm, php seemed to be no longer linked to any modules
 
Oh, well sometimes you have to recompile other stuff, too. But that's normal... sometimes.
 
10:39 PM
well it was beyond me. Seeming as nothing was on the server yet I just reinstalledit back to how it was and decided not to try installing packages like that again
and now there are websites running on it I need to just let it be
 
11:07 PM
womp
 
womp?
 
11:54 PM
those big stone slabs in Super Mario Galaxy?
 

« first day    last day (4948 days later) »