Author: Manuel Lemos
Updated on: 2021-08-05
Posted on: 2021-07-29
Viewers: 435 (July 2021 until September 2021)
Last month viewers: 7 (September 2021)
Categories: Lately in PHP Podcast
The Lately in PHP podcast covered several of those features to explain how they work and what are their benefits for the PHP developers that can use PHP 8.
In the second part of this podcast episode, Manuel Lemos and Samuel Adeshina comment specifically about the PHP 8 Null Safe Operator.
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.
Download Size: 4MB Listeners: 496
Introduction music provided by http://spoti.fi/NCS
In iTunes, use the Subscribe to Podcast... item of the Advanced menu, and then enter the URL above to subscribe to this podcast.
See the Lately in PHP podcast play list on YouTube and Subscribe to this channel there.
Episode 88 Part 2 Video
List of Transcript Sections That You May Read Below
The PHP 8 Null Safe Operator (0m 17s)
Now I'm going to pass to Samuel to start talking about the PHP 8 new features that improve the syntax. Samuel, would you like to go ahead?
Samuel Adeshina: Of course. Thank you. So PHP has seen a lot of RFC to improve the things like type safety and to introduce a lot of syntactic sugars into the language.
So usually there are things that take multiple operations or expressions to get them done. Things like checking for null safe, null types, null values.
So for instance, if you have a variable or a method return value that may return a null value, I need to use this expression somewhere else in your code and you want to check if it is null.
Usually you have to first to create a variable to check for this and check if that is null. And that is writing more lines of code.
But PHP 8 is introducing a way of actually checking this just like the null query coalescing operator. So in PHP 7, we saw the introduction of the null coalescing operator and a lot of us took it with so much excitement, something similar is happening within null safe operator.
So this operator is very similar to the null coalescing operator, it is just a question mark with a forward pointing arrow, it helps you check if a value is null and then performs a certain operation without you having to first write in an expression or an ethos for this.
So I believe this would go a long way to simplify our code just because every code you write is meant to be intuitive and you are supposed to be intentional about it.
So, things like this makes writing code more intentional because they are specific for this use case. So I really think we should we should try it. And it doesn't introduce any breaking changes at all. It only adopts your portion and make it faster and also interesting.
So that is the null safe operator.There are other new introductions to PHP. Let me just check my...
Manuel Lemos: OK. Let me just comment the greatest benefit here is that you exchange all this code just for a single line. And that's a time saver.
That's very important because if you make a good use of your time, you have more time to do other new things that you need to do to evolve faster in your life. So the less time you spend doing a PHP project, maybe you can move on to other projects.
And if you are a professional, and probably you are, you can even make more money in less time. So that is the advantage in the terms of professionalism.
Also your code could be more pleasant if you can read this very quickly. This means if session is null, or if user session is not null, if getaddress is not null, it returns a country.
Samuel Adeshina: That saves you exactly a lot of stress writing your if statement.
Manuel Lemos: Yes, so all this code will be simplified and replaced by this. So it's basically a time saver and probably you'll give you more pleasure. So the benefit is more time and more pleasure. So OK let's move.
Manuel Lemos: What would be the next thing to comment?
Samuel Adeshina: There are other features but before we move on, I would like to say that's something quick because it relates to the other features of PHP 8. The type of person you can refer to as a pro-PHP dude.
So I love the language and any opportunity I get to do any project or write any piece of logic in whatever programming language. I try as much as possible to do it in PHP.
I've been doing um projects in machine learning. And we all know some of the limitations of PHP when it comes to to machine learning like speed and a fascinating introduction when it comes to that has been introduced in PHP 8 and would love to talk about it in subsequent episodes.
How to Buy the Official PHP elePHPants (5m 13s)
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 (7m 57s)
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 (9m 09s)
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.
- PHP 8 Null safe operator
- Buy the Original PHP ElePHPant Mascot Plush Toys
- Comprar a Mascote Original do PHP Azul ou Rosa no site do Mercado Livre
- Comprar a Mascote Original do PHP personalizado com o seu logo no site do Mercado Livre
You need to be a registered user or login to post a comment
Login Immediately with your account on:
No comments were submitted yet.