« first day (1435 days earlier)      last day (3518 days later) » 

@AndreaFaulds awesome, i'd vote for that
btw is it possible to use ternaries without the :else clause? /simple if's
 
@CSᵠ You mean ?:
 
@Jimbo Thanks!
 
12:19 AM
@AndreaFaulds yes, ($cond)?true;
 
@CSᵠ use ?:
 
@AndreaFaulds PHP Parse error: syntax error, unexpected ';'
 
@CSᵠ use ?:
not ?
?: is the short ternary operator
 
@AndreaFaulds so it's actually (false)?:'false'
?
 
@CSᵠ $a ?: $b is equivalent to $a ? $a : $b
 
12:32 AM
@AndreaFaulds i had a feeling this should exist already, thanx
 
12:50 AM
My host is still not sober..
$text = array("4", "4", "4", "4", "4");
$text = array_unique($text);
foreach ($text as $line) {
   echo $line.'<br>';
}
Output:
4
4
Oh wait, its just me..
 
user895378
> PHP is a web-focussed programming language
 
user895378
@AndreaFaulds Is that a "Queen's English" spelling (focussed) or an accident (as we spell it "focused" on this side of the pond)?
 
user895378
Just wanted to mention it in case it was an accident :)
 
@rdlowrey It's always been spelled focussed to me
Apparently it's a UK spelling, huh.
 
user895378
Interesting. Is this one of your highbrow linguistic opinions?
 
user895378
1:04 AM
Oh, okay.
 
I wouldn't say I'm terribly American :p
 
user895378
Cool. So many fancy words over there. Good thing we got this interwebs thing to stop the slow-but-inevitable language fork caused by geographical separation.
 
It's not really inevitable
American and British English have remained mutually intelligible despite being separate for 200 years
 
user895378
True, but does 200 years really rate as a significant time scale?
 
user895378
Wikipedia says telegraphy dates from ~1832. Nearly that same period of time. It's possible the advent of intercontinental communication is a big part of the slowed linguistic separation.
 
user895378
1:15 AM
An interesting topic, either way.
 
Since Levi voted against Integer Semantics I'll need yet another person to vote Yes for it to pass now :/
 
From what I've heard, British English has deviated more from their shared origin than American English has. I blame the French.
 
user895378
TIL there is a demon@php.net with no karma who is able to vote on RFCs :(
 
1:31 AM
@rdlowrey There are other people in similar situations.
 
Yeah, at least two of the No votes on the integer_semantics RFC are from karmaless people
 
@AndreaFaulds I'm not seeing precedence rules for ?? listed anywhere in the RFC.
 
user895378
I don't know ... I'm okay with emeritus people who contributed heavily back in the day, but there kind of needs to be an expiration date for pretty much anyone who isn't Rasmus, Zeev or Andi.
 
@LeviMorrison I should've mentioned them. Lemme add them, I'm not actually sure what they are to be honest, Nikita added the token.
 
@AndreaFaulds That's the only potential issue I have with ??
The rest looks great.
 
1:34 AM
@LeviMorrison between ?: and ||
 
@AndreaFaulds You should throw up an example using those two operators and ??
Would be helpful, I think.
 
@derp No - fuck Webster.
 
@LeviMorrison I will, I'm kinda curious about it
 
@AndreaFaulds there's also Brian Moon (brianlmoon)
 
@LeviMorrison here you go:
oa-res-27-90:php-src ajf$ sapi/cli/php -r 'var_dump(2 ?? 3 ? 4 : 5);'
int(4)
 
1:40 AM
Where's the || ? :D
Also, I'm going to go preemptively vote yes on it.
Please ping me if you think the precedence might be wonky.
Also, regarding votes: some people from the community have voting karma by design, such as Phil Sturgeon.
 
@LeviMorrison Philstu has doc karma
I'm fine with community reps, though.
 
Unless I am mistaken he didn't have it before voting karma.
But, could be wrong.
But you get the idea anyway.
 
So...
oa-res-27-90:php-src ajf$ sapi/cli/php -r 'var_dump(0 || 2 ?? 3 ? 4 : 5);'
int(4)
That weirded me out. But apparently normal ternary does that too
I wonder if that's the case in C, too
Kids, be safe around ternary operators in if statements :D
@LeviMorrison thoughts?
 
I understand the C precedence.
Checking null coalescence now.
 
user895378
@AndreaFaulds Yeah, and people know who the community reps are.
 
user895378
1:49 AM
No one is complaining about those votes.
 
@rdlowrey I'm fine with nobodies voting, so long as they've had their right to vote approved because of contributing
 
user895378
Also, by and large the community reps do a good job of not voting if they don't feel knowledgeable on a topic.
 
For example docs people, pecl people, spec people, internals people etc. Community reps have obviously done something too.
But people with no karma shouldn't really be able to vote unless there's a good reason.
 
@AndreaFaulds He used the same precedence rules as C#
 
user895378
Agree.
 
1:52 AM
@LeviMorrison Ooh
 
Between || and ?:, right?
 
user895378
Tired. Too tired for 10pm on a Friday night. Old age is catching up to me.
 
@LeviMorrison According to msdn, yes.
Also, at least some of the nobodies voting on that RFC are because of me asking for help on Twitter
My fault :p
 
@AndreaFaulds Should that be 2?
?? is ahead of ?: right?
 
1:54 AM
@LeviMorrison ?: is ahead of ??
Which I think is what you'd want
 
@AndreaFaulds So, if I am not mistaken, this is what that says: 0 || (2 ?? (3 ? 4 : 5))
That result should be 2.
(I think)
 
@LeviMorrison No: ((0 || 2) ?? 3) ? 4 : 5
 
Ah, yes.
That would be a helpful addition to the RFC, btw.
 
Showing 0 || 2 ?? 3 ? 4 : 5 and the equivalent expression ((0 || 2) ?? 3) ? 4 : 5
 
1:59 AM
Done
Huh
Maybe JS's || acts like C's ?: because JS doesn't have ?:
Anyhow, I should really be off to bed. Goodnight!
 
user895378
@AndreaFaulds night!
 
user895378
I'm off too. Have fun in Europe, @LeviMorrison!
 
:) Thanks.
Sleep well, old man :D
 
2:33 AM
Hi
I've been very depressed lately because I really wished that I was really good coding in PHP :(
Really good as in very fluent which I'm not no matter how hard I try :(
 
Just keep learning and working with it.
People don't become amazing programmers overnight.
 
That's right but I've been coding in PHP for like 2 months straight and feel like haven't learnt jack-all
 
Do you know other programming languages, or just PHP?
 
plus due to weak in maths, I feel that my logical skills are not as good to program
I've coded in Ruby as well but again not fluent in that either
 
Do you feel competent in any programming language?
 
2:40 AM
Are you fluent in PHP? If so, would you share your journey with me so that I can learn from your experience? Honestly, it would help quite a lot
To be honest, I don't. It's hard for me to code from scratch.
 
I don't have the amount of time necessary to tutor you, but I can give you a few pointers.
 
that would be very appreciating :)
 
Do you like to read texts or watch videos or both?
 
mainly I watch videos but will read text if it'll genuinely help me out
 
Is there some specific area you'd like to learn about first?
 
2:45 AM
Not that I know off. I just want to become fluent in PHP
 
That's pretty broad. Maybe there is a bit of PHP code you've seen that you didn't understand?
 
Yes, I did. I downloaded this Social Networking website in PHP and it was really complicated and way out of my knowledge how its being coded
 
Are you familiar with classes and objects?
What about concepts related to classes, such as member visibility and inheritance?
 
I am, it was object oriented but it seemed quite complicated as I was trying to copy the code to practice and learn by debugging it but I failed to do that. I know about classes and inheritance but not member visibility.
is member visibility same to encapsulation?
 
Here's a link to the PHP manual on visibility: php.net/manual/en/language.oop5.visibility.php
 
2:51 AM
oh sorry i didn't know visibility meant public, private etc
 
:) That's okay; it's helpful to know the terms.
So it sounds like you are familiar with many of the pieces of programming languages but you need some guidance on how to use them properly?
 
I've been recently using these in my classes. I'm trying to create a mini social networking website similar to facebook so that I can learn PHP more and more
 
I think the best advice I can give you is to encourage you to write small, specific functions that do one thing and one thing only.
 
I guess so. Most of the times I can read the code and understand it easily but when it comes to writing it from scratch, I just can't help but copy and paste the existing code and manipulate that.
 
You then build on those small functions to build routines or algorithms.
 
2:54 AM
right
 
Let me show you an example of a bad function.
 
sure
 
public function example()  {
    if ($a == $b)  {
        if ($a1 == $b1) {
            fiddle();
        } else if ($a2 == $b2) {
            fiddle();
        }  else {
            fiddle();
        }
    } else if ($c == $d) {
        while ($c == $d) {
            fiddle();
        }
     } else if ($e == $f) {
        for ($n = 0; $n < $h; $n++) {
            fiddle();
        }
    } else{
        switch ($z) {
            case 1:
                fiddle();
                break;
            case 2:
Obviously the variable names are bad.
The worst part of it is that it does too many things.
Nested ifs, multiple loops inside if conditions.
All in the same function.
 
that makes a lot of sense
 
It also makes it hard to reuse pieces properly.
The more things a function does the harder it is to use somewhere else.
If a function does 2 things and you want to call it somewhere else but don't want one of the things to happen, you can't call it.
 
2:58 AM
what would be a good example of good function from the above bad function
 
I'm not sure this is a good function, but it is certainly better:
 
I know what you mean by that as I can relate to one of the functions that I was trying to do :)
 
function cmp($a, $b) {
    if ($a < $b) {
        return -1;
    } else if ($b < $a) {
        return 1;
    } else {
        return 0;
    }
}
 
I get it :)
 
You can then use these functions which do only one thing to make routines.
They should read like higher-level ideas, a series of function calls with little other logic.
I've having trouble coming up with an example off the top of my head.
Let me find something I've worked on recently.
 
3:03 AM
It makes sense
You're very kind
 
$number_of_tied_accounts = count_tied_accounts($account_list);
$merged_accounts = merge_tied_accounts($account_list, number_of_tied_accounts);
calculate_tree_fairshare($merged_accounts);
The function names describe what is going on, and do only one thing.
1. You count the number of tied accounts
2. Merge those accounts together
3. Calculate the fairshare result on that subtree.
 
I really wish I could code like that too.
Actually I'm not a really good coder when it comes to mathematics functions.
 
You need to focus on splitting each problem into a series of smaller problems.
 
I actually remember doing that once and when it worked, the feeling was great honestly!
 
Mathematics can be really helpful in programming but don't get let that get to you.
Focus on splitting problems into smaller problems.
 
3:12 AM
What is it that makes the programmer a good programmer? How do you remember all those methods and functions and so on to solve a problem
 
Eventually you'll start seeing some common patterns.
"Ah, I've seen something like this before; maybe I can solve it in a similar way."
 
Ha! True, I remember that too!
 
Some things you'll have to memorize, such as basic syntax and general concepts for database operations.
 
Maybe I need to focus more on programming, code more, experiment more with it
 
There are also some patterns that are common enough that they have names.
They are known as "software design patterns".
 
3:15 AM
Is there something useful books and videos that you can suggest me?
 
Definitely.
A big part of programming is having confidence that it works correctly, which means you'll want to have automatic tests that you can run each time you alter code to see if you broke anything.
I can give you hours and hours of videos on that alone :D
Also note that writing functions that only do one thing are easier to test, so that programming principle will make it easier to write tests.
 
I'll have that :)
and I will definitely watch them all :D
 
Search for Google Tech Talks by Miško Hevery.
If you don't have any clue what he's talking about, start over and try to figure it out.
 
From your experience, what would you say how many maximum lines a function must have
the maximum lines it can get too
 
Oh, it's hard to say. Definitely should be able to fit on one screen.
Most should be much smaller than that.
Focus less on how much code they have and more about what the code is doing. Does this code do one idea?
And if it happens to be long after focusing on just one idea, you can probably find good places to break it down into smaller pieces.
I also recommend that you read up on "software design patterns".
 
3:21 AM
Right:)
Which ones do PHP use? Any in particular?
 
I am sure there is PHP code out there using every named design pattern.
To give you an example of finding places to break things down, the code I mentioned earlier:
17 mins ago, by Levi Morrison
$number_of_tied_accounts = count_tied_accounts($account_list);
$merged_accounts = merge_tied_accounts($account_list, number_of_tied_accounts);
calculate_tree_fairshare($merged_accounts);
At first that didn't count the number of tied accounts.
First I just tried merging the ones that were tied.
The function was too complex, so I found a logical place to split it at: finding the number of tied accounts is a separate idea than merging $n accounts.
Perhaps later on I'll want to merge accounts for a different reason, so it's a logical place to split it.
In that vein, the above code could be better because merge_tied_accounts doesn't really merge tied accounts, it simply merges the number of accounts you tell it to. Maybe it should be called merge_n_accounts or merge_accounts.
Maybe talking through that was helpful to you.
 
Yes, it was very helpful and kind of you to take your time out to enlighten me with useful information on this subject
Do you use MVC?
 
I'm glad I could help.
Ah, now there is a design pattern that is... confusing.
It's very good pattern; quite excellent really.
Unfortunately, what every PHP framework/library calls "MVC" is not really MVC as described as the official pattern.
But, they do follow certain principles that MVC has, so sometimes people just call it MVC anyway.
 
Right, which MVC framework do you suggest?
 
None.
No PHP framework is really MVC.
 
3:32 AM
I know what you mean but what I meant was there are some framework such as zend, codeIgniter etc
 
I don't use any of them.
You should always put the problem to be solved above general design patterns.
And since MVC is a pattern, not a concrete thing, using a framework locks you into doing MVC their way.
That may not be what is best for your project.
 
How I am doing my mini social network coding is by having classes and those classes contain functions and these functions are called on pages like profile.php by creating the objects to the classes like so:

$user = new User();
is that the similar thing you do too?
 
Generally I use classes to model data only.
So new User() would create a 'blank' user. It doesn't get it out of the database or anything like that.
 
Alright
 
I'd probably have something more like:
$user = $UserGateway->retrieveUserById($id);
 
3:38 AM
so which one is your class there? UserGateway?
 
$UserGateway is an object that knows how to find, update and delete users.
It could get it from a database, or from a file system; it doesn't matter to the person using it.
In this case it would return a User object, which holds plain data like username, etc.
 
Yea I get it now
I did something similar like $user->getUserSession()
 
It's a little bit more complicated than that usually because things can fail and you have to handle that somehow.
@JamesSmith That's probably a bad thing. Why would a User object know how to get a session? Isn't that the responsibility of a session manager?
 
I have no idea :)
 
Do you see what I am saying though?
 
3:43 AM
I know what you mean but to get the user session, where would you define that function? I've defined it in user class.
 
Maybe in a SessionManager.
Maybe it's just a function not attached to an object.
 
its like this: ($user->getUserSession($user->userID))
userID is always in the UserID variable in User class
 
Your User class does more than one thing.
Let me explain why it would be bad for your user object to know how to get a session.
 
so that I can use the currently logged in userID to do things like fetch user information
 
Let's say your sessions are stored in a database.
 
3:47 AM
Sorry, internet got disconnected.
 
In order to retrieve a session you would need a database connection.
So now your User class needs a database connection.
 
that is defined in user class
like so:

public function __construct(){
$this->db = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
 
Think about that though: a User class that needs a database connection?
Now every time you need a User you have to open a connection to the database!
What if you weren't using the User object to get the session?
What if you just wanted to know something about the user?
 
I really have no idea to be honest. What would be the right way?
 
Still need a database connection!
The answer is to have your classes be responsible for one thing and only one thing.
In my case, User objects are responsible for holding associated things about a user, such as their username.
And a UserGateway is responsible for retrieving a User from somewhere.
(and saving it somewhere too)
Those are separate responsibilities, knowing things about users and being to retrieve them from storage somewhere.
 
3:53 AM
How can that be achieved? If I have the class lets say manageSession and inside it I have DB connection defined then how will the user class connect to the DB? As in, does the User class have to call manageSession class?
 
That's a key point: the user class does not know how to get a session.
Users don't know how to get sessions. That's not their job.
Their job is to know things about the User.
 
But how do you actually mention the manageSession in User class to connect to DB? because I would really like to know that
 
I'm not sure I understand? Could you ask it differently?
 
Nevermind, I guess I'm asking a stupid question lol
 
Maybe this will help; it is one possible way to accomplish this:
$Session = $SessionGateway->getSessionById($id);
$User = $UserGateway->getUserById($Session->userId)
 
4:06 AM
Now I get it
 
That code is a bit simplified, of course.
Sessions don't always have logged in users.
Doesn't handle errors either.
 
I thought you would have to call the $SessionGateway->getSessionById($id); in $UserGateway class
 
No, you want to keep things as untangled as possible.
For instance, sometimes you have relationships between users. You'd need to be able to retrieve the related user by ID but that ID doesn't come from a session.
 
where does it come from?
the url?
 
any regex pros here ?
I want to match "_xxxx^yyyy " where xxxx yyyy can be anything of any length
and replace it with "_{xxxx}^{yyyy}"
 
4:15 AM
@JamesSmith Does it matter? The point is that a UserGateway can retrieve a user if you can give it an ID.
The UserGateway does not care where it comes from.
 
@LeviMorrison I see Levi. Is there anywhere I can follow you or add you as it's quite late here now and I must go to sleep :)
 
I am here a lot, as are many other knowledgeable people.
I need to go to bed too.
This next week I am traveling around, though, so don't expect me to be here for about a week.
 
Sure Levi, thanks a lot for all the informative knowledge, it was very nice talking to you :)
 
:) Glad I could help. Have a nice night!
 
You too :)
 
 
1 hour later…
5:24 AM
Decrypt this MD5 Pls..
2e0e4b05aa6e428593f3b45b710045b7
 
5:54 AM
99c71421c63b41f71704131df4c4da21
 
6:18 AM
greetings
 
6:36 AM
@Kasper have some context? makes no sense so far...
 
 
2 hours later…
8:12 AM
Hello @CSᵠ
@LeviMorrison .. how are you doing ?
 
@Baba yellow
 
@CSᵠ how have you been ?
 
haven't read you in a while
@Baba awesome, thanx, what have you been up to?
 
@CSᵠ stakoverflow ban my IP address
@CSᵠ Not sure .. Send them a mail but no response so i left
 
@Baba wtf ?!
 
8:14 AM
I used so many "is it down or just me" to verify and worked only over VPN
but just tried it now and every things seems to be working
 
@Baba shared ip perhaps
 
@CSᵠ Yeap
 
@Baba whooo happy 50k :)
 
@CSᵠ lol
how did that happen ?
I barely responded to any question in the last 6 months
My last answer was Apr 20 '13 at 13:38
Over 1 year ago ....
 
@Baba you were a few tens_of_K behind a year ago
 
8:21 AM
Sorry I mean Mar 12 at 10:52
Yeah ... stopped when i noticed too much duplicate
and people closing question without even doing any research
 
well, in recent news: I noticed room/11/php kinda be got php-src/php-internals
 
I use comments a lot in HTML ... does it even make sense
5mins BRB
 
9:04 AM
hi
 
9:15 AM
@CSᵠ I think it's more like, room/11 regulars graduated to php-internals
It's healthy, people deeply interested in progressing the language have stepped up and are contributing more deeply
 
cept me, I just spend time looking for kittens on the internet still ..
 
Morning Joe :)
 
9:34 AM
morning
 
9:55 AM
@Leigh breaks BC and consistency after years of history discussing cute puppies and cats and the occasional vamping
morn
 
:P
this is an acceptable break :)
 
10:21 AM
Morning
 
morning
 
hey @Baba o/
mr @NullPoiиteя
 
10:57 AM
yo
 
yo @Duikboot
 
how you doing
 
Besides a terrible cold not too bad :)
 
11:22 AM
@PeeHaa en.wikipedia.org/wiki/… Disregard the meth part ^^ It helps.
I don't remember when I had cold, up until now.
 
@webarto So basically I need to do meth again? :)
 
It's super effective.
 
Will do :D
 
i just created a --help file, funny... not
grep cat tail all fail in the dir
 
I thought 4 persons liked it.
 
11:41 AM
Hello veleryone
 
hello back @akhilesh
 
I am getting the warning message on my page Warning: deg2rad() expects parameter 1 to be double, string given
 
(double) $it
 
and i am using this code to remove warning but it s not working error_reporting(E_ERROR | E_PARSE);
 
Don't
 
11:44 AM
$var+0.0
 
uhhhhm it's php
 
@CSᵠ can you please solve my issue
 
it's automatically casted
 
welcome back @PeeHaa
 
heya @CSᵠ \o/
 
11:45 AM
$binary = (binary) $string;
$binary = b"binary string";
 
@akhilesh yes
 
Hah, this is new for me.
 
@akhilesh What is unclear about the error message?
 
@akhilesh i have e $50 /15min task
 
@PeeHaa i am getting the warning message Warning: deg2rad() expects parameter 1 to be double, string given and i want that this should not display on my page
 
11:46 AM
@akhilesh That is not an answer to my question
 
@PeeHaa i am getting the warning message Warning: deg2rad() expects parameter 1 to be double, string given and i want that this should not display on my page
 
@PeeHaa i just want that the warning should not display on my page
 
@PeeHaa what @webarto said!
 
Forget it. Aaaaaaand it's gone
is the avatar list for other people also missing lots of avatars?
 
@akhilesh translation: I am taking this painkillers (XANAX | ASPIRIN) to remove my toothache, but it's not working
 
11:50 AM
I mean not like tiny avatars, but actually not rendering avatars
 
@PeeHaa could not compute
@PeeHaa chrome?
 
ow nvm :P
has been a ghostery update :D
 
@PeeHaa earlier when i got the warning message and i used error_reporting(E_ERROR | E_PARSE) after that warning message was remove but currently it is not working i don't know why it is not working
 
@CSᵠ I just noticed the number on the ghostery icon in the screenshot :P
 
@PeeHaa someone else reported some strange sh!t with chat and chrome earlier...
@akhilesh earlier you got a different message remember? do you still have that error message?
hmm...
got an idea for a new flag: E_BLIND
 
11:57 AM
@cs of-course that was different warning message but that was also warning message so i think that should be remove by this code
 
needs some serious engine refactoring, but would work wonders for forgotten code on old servers
 
@CSᵠ What about E_CONTAMINATED? :)
 
@akhilesh it's important to read and understand any message like that
@PeeHaa E_DOESNT_GIVE_1_FUCK
 

« first day (1435 days earlier)      last day (3518 days later) »