#phptrick search results
When using #PHP isset(), the language construct hides errors because, ... well... that's what is being tested there. Unless there is an object, where an array is expected. Then, it leads to a fatal error. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
A few days ago, I warned about isset() and a possible #PHP Fatal error. Given that isset() and ?? share the same code, it is not suprising that ?? hold the same trap. That bug should go away, the sooner the beter. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
It is not possible to cast any #PHP enum cases to (string) or (int) even when... they are backed! That looks like a natural feature, though. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
There are, at least, 4 ways to create a closure in #PHP. They all will be callable later. On the other hand, they behave differently to check the underlying method. All is in the timing. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
Dynamic class constants is achieved with #PHP 8.3 class constant syntax, and the constant() function. It also applies to enumeration cases. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP question of the day : when you know that 2*2 = 4 2^2 = 4 (too) 2.5^2.5 = 9.8821176880262.. Where is this 6 coming from ? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
And since PHP 8.0, it is also possible to use the keys as named parameters. It solves the problem to put the arguments at the right place. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP has a 'precision' directive that controls the number of decimals displayed by float values. It default to 14, and peaks at 18, and gives up at 54. Use gmp for large numbers. When changing it, don't forget to reset it to default. php-tips.readthedocs.io/en/latest/tips… #phptip #phptrick
It is easy to create a map from a list of object, using #PHP array_column() and the second argument null. That null represents the whole object, and the third argument is the indexing key. array_column($list_of_objects, null, 'id'); #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP doesn't allow the dynamic creation of class constants (nor methods, nor properties). So, don't try the code below : I did, it doesn't work. Now, how would you make a dynamic class constant, in spite of these limitation? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP allows to use 'class' as a class name in a type. Same for interface, enum... and some others. Hey! I'm also not too proud of myself, but it made me chuckle. php-tips.readthedocs.io/en/latest/tips… #phptip #phptrick
Since #PHP 8.4, we can have properties in interfaces! Thank you, property hooks! #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP can type arguments, properties and returns. But can it type also local variables ? Well, it could, and for a long time. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
When using a referenced argument, the type is checked but it is not garanteed. After execution, it might be different than initialy. Rare, but surprising. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
Indeed, the date() function doesn't support the u and v format characters, that provide milli and micro seconds. That might be a reason to move to new DateTime() and DateTimeImmutable(). #phptip #phptrick 3v4l.org/eFSme
It is Friday, so why not cram as many #PHP operators in one single operation, and make it work? Look at this beauty! Could you make it run? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP mixed type accepts any type, just like no type. But it is also making property unreadable before initialisation. And that's often a useful check. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
A #PHP variadic argument collects all the unused named parameters, along with their key. That way, it is possible to handle them with their name inside the method. On the other hand, array_merge (and some cousins) refuse them, and emits a Fatal error. #phptip #phptrick
So, take a #PHP array, but some value in it (like, anything). Can you make an infinite loop out of this? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
It is easy to create a map from a list of object, using #PHP array_column() and the second argument null. That null represents the whole object, and the third argument is the indexing key. array_column($list_of_objects, null, 'id'); #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
It is not possible to cast any #PHP enum cases to (string) or (int) even when... they are backed! That looks like a natural feature, though. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
Dynamic class constants is achieved with #PHP 8.3 class constant syntax, and the constant() function. It also applies to enumeration cases. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
There are, at least, 4 ways to create a closure in #PHP. They all will be callable later. On the other hand, they behave differently to check the underlying method. All is in the timing. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
A few days ago, I warned about isset() and a possible #PHP Fatal error. Given that isset() and ?? share the same code, it is not suprising that ?? hold the same trap. That bug should go away, the sooner the beter. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
When using #PHP isset(), the language construct hides errors because, ... well... that's what is being tested there. Unless there is an object, where an array is expected. Then, it leads to a fatal error. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
It is Friday, so why not cram as many #PHP operators in one single operation, and make it work? Look at this beauty! Could you make it run? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
So, take a #PHP array, but some value in it (like, anything). Can you make an infinite loop out of this? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP mixed type accepts any type, just like no type. But it is also making property unreadable before initialisation. And that's often a useful check. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
In #PHP array_merge_recursive(), what is recursive? Does it go deep in the guts of the arrays, or does it merges values that look alike? Or something else? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
Since #PHP 8.4, we can have properties in interfaces! Thank you, property hooks! #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
The humble bitwise operators (& ^ | ) have a hidden secret : they work on integers and also on strings. But not on both at the same time. One of the earliest #PHP feature, still available 30 years later. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP methods must be compatible with the one in the parent. Except __construct, which may be different. And except abstract __construct. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP recursive methods are easy, because they have a name. What about closures? arrow functions? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP can type arguments, properties and returns. But can it type also local variables ? Well, it could, and for a long time. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
When using a referenced argument, the type is checked but it is not garanteed. After execution, it might be different than initialy. Rare, but surprising. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
<=> #PHP spaceship operator may be conveniently chained together to make a multisort() tool. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
Just discovered that PHP's array_chunk() is like Naruto's Shadow Clone Jutsu - it splits a big array into smaller, manageable pieces. Perfect for when you need to process data in batches without overwhelming your server's memory 🍥 #PHP #Naruto #Development
Sometimes, you'll find underscores in your HTTP variables, where you expected other characters, like +, . or space. parse_str(), the underlying #PHP function, still enforce backward compatible behaviors. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
When using #PHP isset(), the language construct hides errors because, ... well... that's what is being tested there. Unless there is an object, where an array is expected. Then, it leads to a fatal error. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
It is easy to create a map from a list of object, using #PHP array_column() and the second argument null. That null represents the whole object, and the third argument is the indexing key. array_column($list_of_objects, null, 'id'); #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
There are, at least, 4 ways to create a closure in #PHP. They all will be callable later. On the other hand, they behave differently to check the underlying method. All is in the timing. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
A few days ago, I warned about isset() and a possible #PHP Fatal error. Given that isset() and ?? share the same code, it is not suprising that ?? hold the same trap. That bug should go away, the sooner the beter. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
Dynamic class constants is achieved with #PHP 8.3 class constant syntax, and the constant() function. It also applies to enumeration cases. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
It is not possible to cast any #PHP enum cases to (string) or (int) even when... they are backed! That looks like a natural feature, though. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP recursive methods are easy, because they have a name. What about closures? arrow functions? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP can type arguments, properties and returns. But can it type also local variables ? Well, it could, and for a long time. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
Since #PHP 8.4, we can have properties in interfaces! Thank you, property hooks! #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
And since PHP 8.0, it is also possible to use the keys as named parameters. It solves the problem to put the arguments at the right place. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
When using a referenced argument, the type is checked but it is not garanteed. After execution, it might be different than initialy. Rare, but surprising. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP question of the day : when you know that 2*2 = 4 2^2 = 4 (too) 2.5^2.5 = 9.8821176880262.. Where is this 6 coming from ? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
So, take a #PHP array, but some value in it (like, anything). Can you make an infinite loop out of this? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
It is Friday, so why not cram as many #PHP operators in one single operation, and make it work? Look at this beauty! Could you make it run? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP methods must be compatible with the one in the parent. Except __construct, which may be different. And except abstract __construct. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
In #PHP array_merge_recursive(), what is recursive? Does it go deep in the guts of the arrays, or does it merges values that look alike? Or something else? #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
The humble bitwise operators (& ^ | ) have a hidden secret : they work on integers and also on strings. But not on both at the same time. One of the earliest #PHP feature, still available 30 years later. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP mixed type accepts any type, just like no type. But it is also making property unreadable before initialisation. And that's often a useful check. #phptip #phptrick php-tips.readthedocs.io/en/latest/tips…
#PHP has a 'precision' directive that controls the number of decimals displayed by float values. It default to 14, and peaks at 18, and gives up at 54. Use gmp for large numbers. When changing it, don't forget to reset it to default. php-tips.readthedocs.io/en/latest/tips… #phptip #phptrick
TIL file_put_contents() accepts an array as second argument, and will do an implode("", $array) on it when writing. Who is using this feature? #phptip #phptrick cc /@Girgias php-tips.readthedocs.io/en/latest/tips…
Something went wrong.
Something went wrong.
United States Trends
- 1. Falcons 30.4K posts
- 2. Bears 60.1K posts
- 3. Myles Garrett 2,634 posts
- 4. Bryce Young 16.2K posts
- 5. Ravens 18.8K posts
- 6. Chiefs 31.6K posts
- 7. Ramsey 11.5K posts
- 8. Josh Allen 22.7K posts
- 9. Vikings 30K posts
- 10. #KeepPounding 5,767 posts
- 11. Chargers 21.1K posts
- 12. JJ McCarthy 11.8K posts
- 13. Panthers 27K posts
- 14. Bengals 24.7K posts
- 15. Mahomes 6,976 posts
- 16. Packers 40.8K posts
- 17. Hyatt 4,748 posts
- 18. Troy Franklin 1,265 posts
- 19. Sam Darnold 2,287 posts
- 20. Bucs 13.1K posts