PHP Classes

The Wonderful PHP 8 Features and Changes Part 3: The PHP 8 Named Parameters - 17 Minutes Lately in PHP Podcast Episode 88

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog The Wonderful PHP 8 F...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  


Viewers: 462

Last month viewers: 2

Categories: Lately in PHP Podcast

One of the oldest complaints of PHP developers is remembering the right order of the parameters of many PHP functions that they use.

PHP 8.0 introduces named parameters that allow PHP developers to specify the function parameters by name, regardless of the correct order.

Manuel Lemos and Samuel Adeshina comment specifically about the PHP 8 Named Parameters in the third part of this podcast episode.

Listen to the podcast, watch the video with manually edited subtitles in English, read the transcript to learn more about these exciting PHP 8 topics, and find where to buy the original PHP elePHPants shown in the podcast video.

Loaded Article


Listen or download the podcast, RSS feed and subscribe in iTunes

Click on the Play button to listen now.

Introduction music provided by

View Podcast in iTunes

In iTunes, use the Subscribe to Podcast... item of the Advanced menu, and then enter the URL above to subscribe to this podcast.

Watch the podcast video

See the Lately in PHP podcast play list on YouTube and Subscribe to this channel there.

Episode 88 Part 3 Video

Play Video

Transcript of what was said in the podcast

List of Transcript Sections That You May Read Below

The PHP 8 Named Parameters (0m 17s)
How to Buy the Official PHP elePHPants (11m 21s)
Upcoming PHP Classes Marketplace (14m 6s)
Conclusion (15m 17s)

The Actual Transcript

The PHP 8 Named Parameters (0m 17s)

Samuel Adeshina: But one of the other things that you'll find in other programming languages like PHP are things like named arguments in Python rather are things like named arguments in in function calls.

So you may write a function that accepts probably five different parameters and some of them can be optional. So in existing PHP, you have to write all of them and the ones that are supposed to be optional, you have to know them out and that is inefficient.

And other languages have evolved by creating named arguments where you can just call the arguments that you want to pass in without having to so skip anything.

We've seen with the introduction of PHP 8 this feature added and it is going to really go a long way in helping making our codes easier to read and better to understand.

One very interesting way this applies is in object-oriented programming in polymorphism. So we know that PHP really doesn't do well when it comes to polymorphism.

Polymorphs function calls that are similar but different parameters. And with this, with the ability to have named arguments you can simulate this feature also.

So the OOP community is seeing a great boost in terms of compatibilities with the standards and all of that.

So yes named argument's really an exciting change. And I don't know if you would like to say something about that now.

Manuel Lemos: Just to mention one detail or maybe another detail. But one thing is here. This proposal was sent in 2013. That's like seven years ago.

Samuel Adeshina: Wow! They took seven years to consider it.

Manuel Lemos: Yeah. Patience is a virtue. If you want to get things faster, do it yourself. If you want to do things better collaborate with others.

Here is Nikita Popov, one of many contributors of PHP 8. He did not give up. If you gave up on PHP, you'll never know what you could have learned and have the advantage of benefiting from PHP 8.

And not quitting a language just because somebody said: oh Python is better. Maybe Python is better in one aspect or another. I always tell you, if possible also learn Python.

I am not a Python specialist. I know specialists in Python and I also collaborate with Google. They use Python a lot. I was told that, for instance, YouTube was written originally in PHP. They switched to Python. It's up to them. You do not have much control over other people's lives.

You have control about yourself but if you are open-minded, you can collaborate with others and everybody will benefit here, and me, Samuel, and you that are watching. And if you can help, if you want to help you can tell others: look there is a new episode of the Lately in PHP podcast that is telling about the upcoming features.

The future of PHP is bright. How many times have we have heard that PHP is dead?

Samuel Adeshina: if I had a coin for every time that I heard that, I would have a very huge bank account right now.

Manuel Lemos: Your bank account may still be big sometime in the future. I don't know. It's up to you. But the matter is people think things are dying because they are losing interest in some language because they are being influenced by other fans of other languages.

And that's okay. That's how life goes. Do not worry too much about doing the things with the language that others tell you that is better. Do the things and use the language and the tools and the methods that are better for you.

So here, in this proposal, what you can see is that Nikita Popov and everybody else that  is around the PHP community did not give up. If you give up, it's your responsibility.

Some years ago I said, I have an article that says: the Web war is over. PHP won. But that was a temporary win because whoever is in front today may not be in front in the future.

Samuel Adeshina: I agree with you. We should not try to duel so much on what is better or who is doing this the best way. Well that is important but we shouldn't duel so much on it as communities. We should instead strive to achieve results. And I think that is where we are getting to the community.

Manuel Lemos: Anyway this is a side comment but what I wanted to say is: this feature is great because it makes PHP readable, as Samuel already said.

And it was some thing that was already asked many years ago. Named parameters make your more code readable. Your benefit will be when you maintain this code instead of just looking at numbers that are not very meaningful and make you waste time going back to the manual and now what does this parameter means.

You spend like 10 seconds more to type the name of the parameters and you don't have to remember the order of the parameters anymore. It was a long time complaint. Now it's up to you if you wanted to not having to remember the order of parameters it's up to you to upgrade your code to PHP 8.

And this is a good thing. Good thing happens when you do the good things and make them happen okay.

Samuel Adeshina: Can I just chip in something else? One of the other fascinating benefits of this named arguments feature is you can now have your parameters in whatever order.

So for some reason you may need to do this but right now you cannot in PHP. So if you define your parameters to have maybe three times your function to have three parameters, and whenever you call it they must be in that particular order.

That can be limiting but with introduction of named arguments you can call them in any other you want to. And that gives you the freedom to do things instead of being constrained by rules and all of that.

Manuel Lemos: So yeah. That's a good thing. I'm not telling you should upgrade to PHP 8 immediately. You need to make sure whatever you have in your code still works with PHP 8 because it seems there are some backwards incompatible changes that may make your existing work in PHP stop working.

You need to test first. Give it some time  because if you have a large code base in PHP, it may require some human testing. Automated testing is good. Better than  automated testing is human testing because if you do not test your code your users of your code will test for you. And they'll figure the bugs that you might not know that exist.

Samuel Adeshina: At that time it is not bugs but incompatible features. You've developed nonsense and it will bug your life.

Manuel Lemos: Yeah. It's hard. PHP classes has over 700.000 lines of code. Probably, 50% of that is generated by a another software that I developed to generate a code to do all sorts of actions that people need to implement using what is called ORM.

I have developed a tool called MetaStorage to generate that code. So like 50% of the code of the site is generated automatically. So that's far easier to upgrade to make it work with PHP 8.

The rest of the code needs to be manually tested or tested with some automated tests that exist. But there is no such thing as 100 automated testing because there is always one more aspect that was not tested and we did not anticipate the testing that needed to be performed to test that feature.

And writing test driven code is an investment in time. So we need to evaluate carefully how much testing automatic testing you do before you decide that's the only thing that is good.

I already written a polemic article many years ago. Some people did not like it. I wish to apologize because sometimes I have a different point of view. It's not that your point of view is wrong. It's that mine is different, OK?

Samuel Adeshina: That is quite normal.

Manuel Lemos: Yeah let's be tolerant with each other because exactly we are in the same boat, as we say. It's the big PHP community. We are like seven million or maybe more. Why trying to please everybody after ourselves?

So we need to be comfortable with what we do so let's move on and talk more about the next features.

Samuel Adeshina: So here we have  named arguments.

How to Buy the Official PHP elePHPants (11m 21s)

Manuel Lemos: And we are practically ending this podcast. And it's up to you. This is just one episode of the Lately PHP podcast on which we are talking about PHP 8. We will also talk about other  aspects.

What I would like to say to end this podcast if you allow me, we are doing this podcast is also work, work of collaboration we are not asking anybody to pay us.

We are doing this because we have fun. We are doing this as a part of the content that will be published in the PHP Classes site, as well in YouTube.

And what we would like, if you allow us, is that if you would like to support not only the PHP community as a whole but also PHP Classes, is try to find these in the PHP Classes just to show...

Samuel Adeshina: The best stress relief you need as a PHP programmer.

Manuel Lemos: ...this is the official PHP ElePHPant that was allowed to be produced and sold, by Vincent Pontier from France, the creator of the design. Actually, there one improvement, like PHP 8, think about this is the PHP 7 ElePHPant. The PHP 8 is more like this.

This is the the pink, as you may see. And we are going to also make available the possibility to personalize your elephants with maybe your name, like Carolina, and oh this is the PHP Classes also. These are optional. Actually you need to do extra work to pay that cost a bit more.

And one possibility is this to have the PHP 8 logo. There this is also a design of Vincent Pontier.

We are very, very grateful for him and for his kindness. He's been supporting the site for many years. Not only he allowed us to produce this one but also the previous one which was also an improvement from a contributor of the site.

And we want actually to pay him royalties and he was being kind enough to waive those royalties. And all the money that we can get to to the site is reverted to continue further development.

Upcoming PHP Classes Marketplace (14m 6s)

We want to pay more contributors, more PHP developers to help us to improve the feature that many developers want. Oh I would like the PHP Classes to be better.

And PHP Classes will be better in a way that I hink many people will like, which is, we are going to help developers to buy and sell their own software products written in PHP or maybe APIs or components or courses, many things that will be announced soon and are part of a plan that we have been executing very slowly but is moving on every day a single bit until we get there.

So we hope in the next months we open the PHP Classes marketplace which will be like many markets that are out there on which can help you, Samuel, or other people to have their products be sold in the market.

Conclusion (15m 17s)

So basically that's it. I would like to thank you for the opportunity to listen to us. And hopefully we have provided value in terms of knowledge about the new features of PHP 8, as well features for the upcoming versions of PHP, by versions I mean the other features that PHP 8 has implemented.

And on my behalf that is all for now. I'll like to leave you with the last words from Samuel. Last words for now. He is not going to die okay?

Samuel Adeshina: Thank you for this episode about PHP 8. And I would just encourage you to check it as soon as it is released which is hopefully in less than two weeks from now. 

Manuel Lemos: OK. Let's see us again soon. If you would like to propose topics or even participate in the podcast with us, just contact us. We're going to make available the contacts.

We are very accessible and anybody can contact us. Send us emails. Send us spam. Send us complaints. Send us complaints. Send whatever you feel it's right for you to comment. So we will be waiting for your comments, or not, it's up to you. On my behalf that is all for now. Bye.

Samuel Adeshina: Thank you. Thank you. Bye.

Show notes

You need to be a registered user or login to post a comment

1,615,540 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:


No comments were submitted yet.

  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog The Wonderful PHP 8 F...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)