 Hi, I'm Derek, I'm European, I live here in London, I'm PHP 7.4's release manager, which pretty much means that every month or so I have to make packages, make sure that the security patches got merged and then release things by announcing those in the mailing list. Today is the release date of PHP 7.4.3, so after this presentation I'm going to have to release that. I also work on XDbook, you might have heard of that, if not please Google it, and if you have questions, feel free to ask me. If there's anything during the presentation I usually would invite you to ask the questions by raising your hand, but I won't be able to see the hands, so do the questions at the end of the presentation, I think that would work better and maybe somebody can run around with a mic, I don't know whether that works or not. I like maps, I like beer, I like whisky, some of these things will come back in examples, and if there's any further comments feel free to ping me on Twitter, it's also in the bottom of my slides. I can't quite see that there, but that's okay. Alright, so what is the biggest thing in PHP 7.4? It is type properties. Now you know how I said that I like whisky, so my example, I also like using emojis in my class names. I wouldn't recommend you do that in production code, but at least put some color to the slides here. So properties you can already have in PHP 7 or PHP 5 or even PHP 4, but what you can now do in 7.4 is you can also add a type to it, which is new and pretty cool. So in this case we have the Republic Private or Protected, and then you have a type name, in this case int for integer, there's a number, you can use class names, you can use fully qualified class names, the namespace in front of it, as well as nullable versions as well. So the bottler can either be a class, sorry, an object of the bottler class, or it can be null. You can also make them on static properties. Again, the type name comes after the public and static keywords. You can't, of course, have a type called static because that gets confusing here. You can use default values for them. So in this case the int rating 92, that sounds like a pretty good whiskey to me if it's out of 100, and then you have things like nullable strings. And then the last bit is that it is also possible to have multiple properties in one row, but I think that most coding standards prohibit that, and I would probably not recommend you do that, but it is possible that the keyword public would count for both of those property names that you've defined, and so will the type. So this has public bull, chill filter, and public bull coloring added. Now, how does this actually work? Now, if we have the following bit of code, again, don't use emojis in your real code. Well, would you guess the output of this one? What do you think this output? Anyone want to shout out? An error? Yep. I heard an initialized property. Some of you have been using PHP 7.4 or reading documentation. That's mean. But yes, it will give you an error message, because this property h hasn't been initialized yet, and if it's not been initialized yet, you don't know which type it is. So PHP doesn't know what type it is, which means that any time you access an initialized property that hasn't been set to any value, default value is a set value, then you'll get an error throwable. So the initialized state is checked when reading properties. Okay, next one. Now, this bit of code, again, the distillery property has been defined as a type distillery as a class. I set it as a string. What do we get as output? You get an error, right? Because that's what you expect. It must be an instance of distillery, but we use a string. So type validation is used when writing two properties. Okay, so what's the output as this one? In this case, I'm not setting the distillery, but I'm setting the int, the h to the string 29. Anybody wants to guess what this does? Can't hear anything. But this works. This works fine, because type coercion is still being used. The script isn't doing strict typing, because we didn't define that for the script. So type coercion still works. It gets automatically converted to an integer just like it would do for a argument, for a method or a function argument. So when you define strict types, then, of course, you'll get the error saying that it's the wrong property type. That makes sense. On top of the introduction of type property, a few other things have also been changed or actually added to PHP's type system. Before PHP 7.4, if you would inherit a method, you would have an overloaded method, then all the method arguments as well as all the return types had to be of the same type. Now, PHP 7.4 relaxes this so that it follows the list of substitution principle, big word. I hope to explain it a little bit here. But it would allow you to widen types or narrow types depending on whether you have an overloaded either argument or return type. So let's have a look at the return types first. If you have a bakery, a bakery makes bread. That is quite a wide range of things, because it includes muffins and whatever things, right? Bread-y things. A patisserie is a more specific type of bakery, and it would only make baguettes. I mean, that's silly examples, but hopefully you get the idea of a more specific type of bakery. So let's have a look at the return types. They are just out of this. Which means that in this case, a return types are covariant, meaning that they can return a more specific type. Because that means that any time you use this overloaded class in any context where you originally would accept a bakery, that is still fine, right? Because the return can never return more than the original class or original method might have expected. So restricting the return type. That's called covariant return types. And in this case, you get a fatal error because we're doing the all the way around. We start with a more specific type and then widen it in an overloaded method, and you can't do that because originally classes that would have made use of the original class wouldn't necessarily understand how to do anything beyond using a baguette. They don't know how to handle all the other breads, for example. So they cannot return a more broader type, but they can return the same type. Now, the argument types are exactly the other way around. So in this case, we have the class asterisks. We need to get the example somewhere, right? And asterisks home spores, which is quite a specific type of animal. Now, any class that has an extended method is fine to accept a wider range of animals because classes, this method could then decide on its own to handle the wider class of animals and then also handle the bore case, for example. So method arguments can accept a wider or a broader type range or the same, but you can't do it the other way around because that would mean that in a context where you would usually use asterisks as a class, you wouldn't be able to use goals because it would only be able to handle a narrower type, in this case, a bore. It's a bit of a tricky concept, but it does make sense if you look at it. You basically need to say, if I have an overloaded class and method, can I use it in the same context that I could use the original class and method? Now, there's one addition to this, which ties in back to the properties, the property types. So property types in PHP can only have the same type. In this case, they're the same type. They're both planets, so that's fine. Because properties are both something you can read to, sorry, write to and read from, and because of both these constrictions, in order to be able to use a property in an overloaded class, they have to be the same type. So we call these invariant property types. And if you do this wrong, you get an error and you get a complex subject. PHP 8 is going to make this more complicated by also having union types. And I need to figure out some of the better examples in that case. Okay. There's a whole bunch of smaller things in PHP 7.4. I will go through those a bit quicker, and then we go back to slightly more interesting things. So it's a bit of a big mix of things in here. PHP already had an assignment operator. It's the equal sign or the percent equals, not percent. Sorry. S-tricks, equal sign, but basically change the value and angle, right? By doing a multiplication. We have something like the null coalesce operators means that if this first, if the bit behind the equal sign is null, then we use the value, the string value behind it. But you still had to duplicate the whole property that you're going to set to as well as the one as you're comparing with to be able to use this value or default value. In PHP 7.4, you can now do this in one go by using the question mark equals operator or the null coalesce assignment operator. It can be kind of handy in this kind of situation where you need default values, for example. The spread operator is something that has been added to also be able to use this in a literal, in an array literal. The dot dot dot or spread operator, whatever you want to call it, you could already use to accept an array of arguments, sorry, extra arguments to a method that then will be put in an array that would have been, in this case, apples as an array. And these things, you could already do 7.4 extensives to be able to inline array literals in another array literal. So in this case, we have an array called apples. We have a red apple and a green apple. And then we have an array fruit where we have a pear, a peach. Then we embed all the other elements from apples in there. And beyond having apples as a static array here, you could also use an iterator for that, for example. And then at the end, we add a strawberry and a tomato. And then when you call implode on them, you'll see that we get our lovely fruit salad. Now, people complain about it. Tomatoes don't belong in a fruit salad. But I got it as criticism in one of my previous versions of the song. But I'm going to leave it in. All right. There's a whole bunch of code that you could write in PHP that is really silly. And of course, everybody makes silly mistakes. But in PHP 7.3 and earlier, you would never get a warning on this. It just returned no. And in PHP 7.4, it turns this into a lot of warnings. So the first one we have, we set it to false. It gives you now five warnings or notices in this. The first one says, try to access an array offset of value of type bool that gives you a warning. And then the square bracket 2 will give you offset on type no. The 3, the 4, and the 5 will all do that. Which is kind of handy, basically show you that you're doing something wrong. But otherwise, you just get no. And it's kind of hard to find, because it could either be the 1, 2, 3, 4, 5 array index that would have been different. And you wouldn't necessarily know one. It will also do this array offsets on numbers. Like I have in the second example where var array is 1, 2, 3. Var 0 is, of course, the number 1, 2, 3. But you can't take the one offset out of a number. So you can error for that. And similarly, you'll get the same kind of warnings if you do this on arrays with no in the last example. Something a bit bigger in PHP 7.4 is something called FFI, foreign function interfaces. This big disclaimer is absolutely necessary. FFI is a really good way of talking to C libraries directly from PHP. There used to be an extension in PHP in PACKLE a long time ago for PHP 5. It's called XFFI. We also named that X dangerous, because it was the most dangerous way of making PHP crash. Not because it was wrongly implemented, but because it's really hard to do, because in order to make use of this foreign function interface, you need to know how you interact with C code and how pointers work and memory management works and things like that. Normally PHP developers are not necessarily all too familiar with that. So this is kind of a harder way of doing this. Or let me say this is an easy way of doing things with C libraries, but it is a harder way of debugging this kind of thing, because you have to do it both C and PHP. So this is bundled with PHP 7.4, but it isn't enabled by default because it can be kind of dangerous. Also consider this experimental and there's no documentation or very little documentation. In my opinion, this should not have been part of PHP 7.4. I think it should have been in a PACKLE extension for a while and then introduced in PHP 8, but not always my opinion counts or it counts, but don't always agree with me. So now how do I use this? I'm not sure how many of you have seen that C code, so I'll start with a very simple function, which I have in the library that I've written for doing calculating the position of the sun in the sky. Basically what the arguments mean is like the double the D is a time or a point in time. It is not Unix timestamps, but it doesn't particularly matter what it is. You get to Unix from... Oh, this doesn't work on the screen. I always keep forgetting that. You go from the Unix timestamp to the number that it needs by this calculation. I can't actually remember what it is. But where in PHP, you can really return only one return value from a function. That's the same for C. But in this case, this function needs to return six values. And in C, it's a common way to do that as an API by using, by passing in the pointer to where you want to store the value in. And in order to, from CLAN to do that, you need to make sure that you have created space for this pointer that the sun post function is going to write into. PHP doesn't really have that concept, so it makes it a bit harder to explain. Okay, so what the function does is you give it one number and it returns six numbers back, which tells you where the sun should be in the sky. Now, how do you use that? From PHP Lens, you use FFI load. You give it a header file. And in C, it's a common way to have header files defined in H-files. What FFI implements is a very basic part of H-files that only will understand function definitions as well as type definitions and round-dru pre-processor macros and stuff like that. So it's a very stripped down parser of header files in C. So this variable FFI now holds this, well, it's basically an object that does marshalling for all the function that are defined in this header file, in this case, sun post. Now, because we use this pointer thing, we need to create places in memory where it's to store these values in. And because this is done with a C type, it's the double C type, although this is the same in PHP. You need to create these five arguments here. You need to allocate an FFI object that has the exact same type as what the header definition says. In a menu called a sun post function, you give him this date here. I'll have to use this mouse. You put his date in here. And then you get, by passing in the address of the containers that you made, because that is what the s-strix does in front of the return types in the header file, you can then the result of the spec. Now, this is a trivial example. But it took me quite some time to come up with this because, as I said, there's no documentation. So you need to come up with, well, how do I create memory structures? Well, you did it by FFI new. How do I pass it in here? Well, I'm going to go back to the FFI address. In the end, I think this could be quite useful for writing PHP extensions that you now will have to write C code for. Write them in FFI, which is basically writing them in PHP. But it does mean that you could compose or install these PHP extensions without having to recompile anything. So I think this is quite powerful. But I think it is more something to be used for people that already know how to write C and want to make all the libraries available through Compose without you as a user having to compile any new extension. So I think that's where the feature is in. All right. I can see you, so I can answer your question. All right. Okay. So the question is, does this create an object? It doesn't really create an object at all. The FFI variable is basically just some magic that makes this work. So there's no actual object. There's no compilation happening whatsoever. No. All right. The next big thing is preloading. Well, or so we thought. I'll give you the caveats in a moment. Opcache is an awesome tool to make sure that PHP doesn't spend lots of time recompiling or parsing your scripts every time it sees a new file. It is awesome. But everything in PHP is currently based per file. Which means if you have a file defining a class that extends another class, and that class that file hasn't been loaded, PHP uses auto-loading mechanisms, right? And that still works fine with Opcache. But for every time it sees this file in every new request, it would still have to check whether the inheritance works, whether the function arguments match, and it will have to do more work than in PHP 7.4 because of the type properties. It has to do quite a bit of work still. Now wouldn't it be great if it wasn't a way of PHP doing this up front before it even starts running your script? And that is what preloading is about to solve. So in PHP 7.4 has this new any directive called Opcache.preload of which you can specify a PHP file which will be run before PHP's request cycle starts and where you can preload code. Now as a small example of this, on the command line you turn it on by Opcache Enable 1 which you need to have. Opcache Enable C Lidled 1 because Opcache usually only works in a web server environment. And then the extra argument is Opcache preload equals the file name. You can of course also do this in PHP I now. Now the moment you do this, through this preload file if you change them on disk it won't change anything in your application. In the only way of refreshing the code that has been preloading is by restarting PHP FPM or anything else that runs PHP. Just something as a cave yet. Now how does this work or how do you make use of it? In this case, this little script what it basically does, it has the underscore preload function and the only thing it does it basically loops over all the argument files in the current array. If it's a directory, calls itself it's basically recursive way of finding all the PHP files under a certain path. In this case, var www send framework library. And for each of these files that it finds it calls opcache compile file. It does all of this and then at the end Opcache has already pre-discovered pre-resolved inheritances and all the abstractions resolved all the traits that you might have used so there won't be any overhead of doing that per request which of course means that you end up speeding things up. It's not a lot but it is about 10% which is always worthwhile to have. So cave yet is about preloading it doesn't work on Windows I can explain at a smaller point later why it doesn't work and before PHP 743 it's not really it's a bit crashy in places so let me put it away. So wait until later today if you want to play this PHP 743 should have all these things resolved but it still won't work on Windows for reasons that I'll leave for some other points all the time. Now, I spoke about f of i a little bit the stage that is really slow in using f of i is looking at all the definitions in the h files now if it is only one line with the send pass on previously that's not a lot of work but if it's a more complicated API that takes quite a lot of time but you can hook preloading and f of i together and in this case in my preload ink the one that I used in the previous slides to load the send framework I can also use f of i load give it the header file and then in the header file that I'm loading I have my function definition for f of i load as well as the f of i scope the f of i scope you can then use later in your script to find this little marshaling object f of i to then call the functions again which is what I've done here now this is going to be fun for the future but I wouldn't quite say this is primarily to use yet I'd wait until 745 or 746 to get to the production I would say all right so with type properties come in other problems some frameworks symphony in this case uses a hack to find out whether arrays are references of each other and it uses like a side effect in PHP where if you assign an array although it copies over the main array array elements in there if there were references to other things it will still keep these references it wouldn't duplicate these bits and symphony uses that for finding out whether things are reference or not in PHP 7.4 you can no longer do that so there's a new class part of a reflection it's called reference reflection and you can use that for finding out what is a reference to each other I have a very small example of an array element I create two references one to the second element in the array and one to the third one then I add an element to the array the fourth element to the array which I then also make a reference to the third element in the array which is the number two I really should have made this one based and not zero based for this to make more sense in an example in any case with this reflection reference you get back something that represents a reference or you get no if it's not a reference so let's have a look at what the script actually outputs for the first one for the fardump r0 and r1 it returns first no because the first element in the array to zero has not been referenced anywhere so it's not a reference whereas for r1 which is a reference which you see here as a so that doesn't work a reflection reference you get back as an object and then all the other ones you can get the id out and if the id is the same then you know that these things reference the same element now this is something that I don't think many of you would be using or should be using but it is there in case you relied on this additional behaviour which you can see here in the pjp7.3 and earlier there is a new custom serialisation mechanism because two of them isn't enough there is a reason why this has been added the serialisable interface in PHP has issues in such a way that if you serialise lots of nested objects and serialising only one of those objects that have been embedded in this serialised string you can't really do depends on context potentially done earlier in the string so you can't plug out only certain bits to unserialise reliably so that is the problem with the serialisable interface the sleep and wake up magic methods are not powerful enough to do any useful things because with sleep you can only specify the property names that you want to serialise basically which means you can't do any calculations you can't do type checking and stuff and that so that has a deficiency so the next one in 7.4 is two new magic methods they are called unserialise which if available you can use to return the property names and the values that you want to serialise so in the example here sorry when we call serialise here what we are basically returning the property T or we call it T that is shorter than temperature and in that we store the temperature and then when we are storing this by using underscore underscore unserialise then we plug out the value of the temperature back out of the array now if you want to do this in a nested way you can but you need to do this yourself so in this case we have a fire class that has serialised and unserialised and then we have a star class that extends fire so how you would serialise from that is then you would do the properties of the class that you are doing and then you call parent underscore underscore serialise and the class has been extended to then serialise that part so it is up to you now whether you would serialise the properties from classes that you have inherited and of course if you do that you also need to restore them by calling calling parent unserialise in underscore underscore unserialise it is the same thing as setting up classes with constructors and destructors you are supposed to call parent parent underscore construct to set up things defined in the parent class and then you get this lovely string that is on the bottom of the screen it is not particularly interesting PHP 7.3 if you wanted the hash extension you had to enable it and PHP 7.4 is always there by default which is a great move function like password hash and password verify are always available now and everybody of you should be using that if you do anything with passwords yeah I know this is boring PHP 7.4 has new features we also removed a few features or we removed a few extensions from the core distribution to be more specific x-recode anybody of you ever use that I have but that is probably 15 years ago alternatives called iconv is a lot better the recode library that the extension used hasn't been updated since 2001 old software shouldn't really be used xwddx any of you have used that for anything it sort of started at the same time as SOAP of course this has now been surpassed by using JSON as a transport mechanism so this extension hasn't been removed yet and there is no alternative for it and it has been moved to the PACKLE extension repository which we sometimes refer to as subarea because these extensions go to freeze basically and then the exa-interbase extension which has been removed from the core distribution had no maintainers the moments the vote for removing this extension came through a few maintainers that apparently existed but didn't interact with anybody else saying we're removing this, we're maintaining this well, you're a bit late now we did ask for people whether they were maintaining it so I'm happy to announce that although this is no longer part of the core distribution people are maintaining it again which is good news and they can do this in their own leisurely time in a PACKLE repository without having to wait for the PHP release cycles which happen basically once every year so I like talking to people about all the stuff that makes into PHP and it's a modern thing tonight you start with a podcast so I started a podcast last year called PHP internal news where I get to talk to all the people that are things with PHP now because there are so many features in PHP and it gets kind of boring to talk about it what I just sort of want to do is also introduce you to people that actually work on the code and with that oh the sound actually works, that's great so that's the opening to tune so what I'm doing is every time I talk to somebody I have them introduce themselves and I end up talking to a lot to a specific person he's Nikita Popov he's basically responsible responsible for pretty much 80% of what gets added to PHP but let me introduce myself so I'm Nikita and I work at JetBrains to develop PHP particular writing song nice RFCs that we can discuss in this podcast this was episode one from 20 times to him or something like that he gets a little bit annoyed with me bugging him anytime he comes up with something cool again in any case the first thing we spoke about was saying a string and number comparisons you know that PHP is kind of weird with comparing zeros to strings with zeros in it and so on so you made a nice RFC for that however this never made it to a voting so this might make it into PHP 8 it's kind of useless to talk about in a PHP 7 but it might show play them hi everyone I spoke with Joe I work on PHP and related tools that's me so Joe he does kind of interesting extensions like slightly on the edge kind of things he did the parallels extension for using some parallel execution in PHP but I spoke to him about something called re-references so re-reference that actually made it into PHP 7.4 is a way of creating a reference to an object without keeping a PHP memory manager reference to it and this is important in situations where sometimes you have like an ODM or ORM that keeps objects meta information about objects that are loaded from the database in memory but the way how what currently happens is that they usually create like a big array with each array element having a link to the object and then the meta information but the moment you do that PHP can never free the memory associated with these objects anymore because there's a reference to it which isn't really particularly performant so what re-reference allow you to do is they allow you to create a reference to an object but it doesn't prevent the PHP memory manager from freeing the object if there's no normal other reference linked to it which is kind of a useful thing to have and the way how this works is that there's a class called weak reference and you can construct a weak reference by using the create method on that static factory method called it by the object and then you get a weak reference class that encapsulates that object so and in order to get the object back out of it you call the get method out of that and that returns either the object or no if PHP's memory manager has freed it for other reasons so in this case I can't use to keep forgetting about that we have this class called ghost it has a method called boo which echoes boo I mean what else do ghosts do so we create this object we create a weak reference to it and then we call get on the weak reference and then we call the method boo on it when we then unset it and try to get the object again it no longer exists so first thing it says boo it is no in evil code if I would have tried to call the boo method directly on this no of course you get an exception because you can't call methods on no so you do always need to make sure that the reference or the weak reference is still valid before you do things on it which is kind of useful thing to have so that made into 7.4 PHP 8 will have something extended of this called a weak reference map but this is PHP 7.4 talk I am still Nikita and still working on PHP core on behalf of JetBrains ok so Nikita again we spoke about short arrow functions and short arrow functions is a new way of writing closures but in a short hand form so traditionally in PHP 7.3 and earlier if you want to have a closure that adds two numbers to each other we have to do arrows the name of the function function as a keyword the arguments that are being passed into the function when it is being called use the use keyword and then the why in this case is all the arguments that are bound from the outside scope to also be able to use inside a closure now what you can do in 7.4 is the following you can define a closure not using by the function keyword but by using fn combined with the arrow following the initial function you still have the arguments that you pass in into the arrow function which is the x but you don't have to import with use all the other variables from the surrounding scope anymore this is of course a lot shorter to write but it also has additional benefit that you don't have to use the use keyword to implicitly bind variables from the outer scope into the closure now this is mostly useful for things like this where if you have like an array filter you only want to keep in your array everything that is already part of another array that we do in the first example with an array here in PHP 7.4 you can write it a lot more shorter by using this shorthand or short array function and in my opinion it makes it a little bit more readable now the implementation in 7.4 only allows a single expression after the arrow it is possible that in future versions of PHP we would allow for multiple lines which of course is currently what you can do with a traditional closure but also has to keep this additional benefit of having the variables from the outer scope implicitly bound to the closure themselves as well but that might be PHP 8 or not all right PHP 7.4 ties up some warnings that depending on whether you implement a class sorry whether a class implements an interface any arguments in the signatures don't match you get a fatal error but if you did it between two classes you would only get a warning and PHP 7.4 these things are being thrown together to make sure that they always behave the same but also that they don't make into PHP 7.4 PHP 8. again, sorry have to wait until the end of the year question for you, what is the output of this little script I'll give you a few seconds the correct answer is they shouldn't have passed code review because nobody should write code like this so in PHP 7.4 this now adds warnings it outputs 4 by the way go try it out if you want later in PHP 7.4 it will now show you this it will show you a deprecation warning saying that you can't use nested ternaries unless you use parenthesis to indicate what you really mean to do in PHP 8. it is possible that you'll get a fatal error if you don't use parenthesis but I'm not sure whether that actually be merged into the language yet because of course doing that breaks code we don't like breaking people's code so I'm going to try to show you this what is the output of this example what did I hear? you shouted something sum 3.7 no the output of this is actually just 7 you want to guess why? I will try to explain it the dot and the plus operators have the same precedence meaning that it will get executed from left to right so the first thing that PHP does it does sum the number 3 to it so that results in the string sum colon space 3 then we add a number to it and the moment you use a plus both operands need to be number what is the numeric value of the string sum colon space 3 it's 0 and then it adds 7 so the result is 7 in PHP 7.4 it says the behaviour of unparan unparan . Everything you can do is change the page of six . and then you can choose to change the page of the unparan which is what you expect to be happening. These subtle changes can potentially break quite a lot of codes. so when the Cheater wrote this he looked at the top thousand PHP products on stack over full done but all of these were bugs and so we're pretty confident that anywhere where people do this it is never on purpose and in that case that makes it an easy decision for us to then break this kind of code and eight because if it's bug in all the case that we can find us pretty sure it's going to cause issues that you hadn't expected in your own code somewhere as well. Okay I have Nikita again no worries I won't play his soundbite over and over again. It's a simple change in 7.4 is that you can now throw exceptions from the two-string method. In 7.3 you couldn't and you get a fatal error that says method explode to string must not throw an exception. In 7.4 it will still get a fatal error because you haven't called the exception but you won't get a fatal error because you are throwing exception from a two-string method which is kind of handy it's a minor thing but I guess it makes sense at some point. Simple change to the language quite a big change internally in PHP because two-string is used in so many contexts that and they all had to be made safe for them also being able to do with an exception being thrown from that. So sometimes these things look simple but are actually quite a bit harder than they look like. And Scott Dotson I got involved in PHP in my early themes. Okay sometimes the sound quality isn't the greatest. This was Scott and he made a simple change that that me personally calls the most amount of grief in my own code. What is the output of this script? Base converts converts the string from base 16 in this case to base 10 that's so hexadecimal to decimal. What is the output of this? If you can guess what the answer is you're pretty good with this. I'll give you I'll give you the answer it is 237 no warnings or anything like that. How does it get to 237 here? Well basically what base convert does it ignores everything it doesn't understand for that base which means it only sees the e and the d in the string and hexadecimal ed is 237. Yeah great isn't it? PHP 7.4 this will now say deprecated invalid characters pass for attempted conversion. Now some of my code I had used this as like a cache key for something at some point but it had a minus character in it and minus is of course not part of this so they're then filling up my log saying that I did do something wrong actually that code is used in this presentation so I had to go through all these slides to make sure that the templates were cached otherwise this error would have actually shown up on my slides giving the presentation. Yeah I haven't fixed that code yet I should win. Bishop would you mind introducing yourself as well? Yes I am also a full stack developer have been using PHP since 2003. Okay so Bishop and Scott got together to add another syntax trick to PHP 7.4. If you have big numbers it's sometimes really hard to see how big the number is because well if you would write this down in like text you'd use a dot or comma or whatever or an apostrophe between a thousand right and PHP could never really do that but you can now in PHP 7.4 you can use the underscore between numbers in numeric letters to make these things easier to read. It also works for all of the other situations where you can have a numeric literal so it works in like floating point numbers where you can have the underscore between every third where you cannot have the underscore is between the three and the dots and the dot and the one it has to be between two numbers and if it's a hexadecimal number the a to the f also count as a number you can so in this case I use that for pie it didn't pie didn't fit on my slide it's kind of it's a joke it's a mouse joke I'm sorry too early for jokes but I think where this mostly makes sense in cases where you have like so like the TT watching is a little too that I that I've extended to to read the date of my watch and it comes in all kinds of hexadecimal numbers and boxes and stuff like that and these things you had to hard code and by being able to use the underscore that actually make that code quite a bit easier to read or when you have to deal with binary things for turning on the IO ports on your Raspberry Pi and stuff like that I think this is a more usable case than just doing for the big numbers because in general it's very unlikely that you have like constants for these big numbers in the first place where you absolutely should never use it for is for things that aren't actually numbers now hopefully you never hard code a phone number a credit card or the social charity number in your PHP code if you do you probably should find a different job in my opinion and that's of course you're doing testing with the payments right where you sort of have to hard code your credit card but remember these things are not numbers a credit card is not a number you don't do calculations with a phone number you don't do calculation you don't add one to the number now I actually don't know if this is a real phone number so please don't call it I just matched up some numbers again I probably should have added an a or something in that to make sure yeah so don't do that but you should never have Thomas in the first place hi so my name is Peter Brown I'm a full stack developer I've been working with PHP for almost 10 years now so this is a curious thing most of the people that did some of the smaller changes to PHP 7 for they weren't original C developers they were all working on their PHP code they found something wrong with PHP and they came up with an idea they'll maybe make PHP a little bit better so I write an RC for it some of them can write their own codes their own C codes to actually implement the features but many others went got together with somebody else that is more familiar with the code in this case I think Theodore spoke with Bishop again to then implement a feature on PHP so you don't necessarily have to be a C developer to propose changes to PHP but it would be really helpful if you at least have some patch it doesn't have to be a fully fledged patch but it needs to be something that it looks like it is implementable because sometimes IDs are great but implementations are really hard to as an example generics I'm sure all of you would love to have those in PHP but that is not a simple task for example in any case Theodore came up in our suit to deprecate the curly brace method for accessing array elements and string offsets so PHP 7 4 will no longer just show you 5 5 SS but it will also show you the warning that the array and string offset access with curly braces are now deprecated Hi I'm Mateo Becati and I'm a PHP consultant mainly I've met Mateo several times he helps organizing the PHP day conference in Italy and he likes PDO and he likes using newer fangled operators in his in his SQL statements so in the last few years relational databases like MySQL and PostgreSQL have all that JSON kind of style things in order to get along with the times where you have like document data source like how to be among them be for example and the way how they implement all this interesting new features is by introducing new operators in this case it's the question mark operator now the question mark in PDO as you probably know is basically a placeholder for value so you couldn't use this SQL statement that wasn't me I don't know what happened there any case I'll just don't continue I'll just continue talking you can't have the question mark because this is a value right it represents a value operator so you need to then um I should call that escape it to be able to use it so that is what Mateo provided he ordered an RFC that allows you to escape the question mark and the way how you do that is by duplicating the character now so instead of having one question mark you get two question marks suddenly now that looks a bit weird because usually you'd expect things to be escaped with a slash in front of an in strings but in SQL it's already a common thing to escape operators that needs to be escaped by duplicating them so in this case instead of having the json call question mark foo you get json call question mark question mark foo so it doesn't interpret that specific question mark as a placeholder for value been in stats use it as an operator okay I'm not quite sure what's going on I only have two more slides so the last slide I can just talk about it this slide is not important is all the deprecations in PHP 7 form there are a whole bunch of things that we have removed from here from the language that almost none of you use the real type is basically a synonym for double type so we don't need this anymore there's some constants that are not there anymore that's the filter sanitize magic quotes filter hopefully none of yous even know what is anymore there's some other code that still made use of magic quotes yeah that's been removed PHP 5 4 a decade or something ago and a whole bunch of other things that none of you really use very much or we couldn't really find any evidence for for people still using it's still flashing like no signal linked at me here distracting me I don't know it's definitely plugged in and so yeah these things are removed I wasn't going to throw to all of them one by one anyway but have a look at the slides when they get published to find out whether these things affect you or not