Float Precision Issue

Does 0.1 + 0.2 equal 0.3 in PHP? The answer will surprise you! Float precision trap that catches everyone!

#php #phptricks #float #precision #comparison #phpquiz

https://www.youtube.com/watch?v=J5nYvIAH9GA

Float Precision Issue #PHP

YouTube

PHP String Increment Magic

Wait for it! PHP can increment strings. See what happens with 'Z'++ and '9'++. This will blow your mind!

#php #phptricks #codingtips #programmingtutorial #phpstringincrement #stringoperations #phpoperators #phpquiz #codingchallenge #phpshorts #phpweird #stringmanipulation

https://www.youtube.com/watch?v=BRIbAfafHSg

PHP String Increment Magic #phpshorts

YouTube

PHP Variable Variables Magic Trick

Stop scrolling! PHP variable variables create dynamic names. See $$var = 'world'. This will change how you code!

#php #phptricks #codingtips #programmingtutorial #phpvariablevariables #dynamicvariables #phpfeatures #phpquiz #codingchallenge #phpshorts #phpadvanced #variablenames

https://www.youtube.com/watch?v=HHBwIoQInhs

PHP Variable Variables Magic Trick #phpadvanced

YouTube

PHP Array Destructuring Hack

Wait for it! PHP array destructuring lets you swap variables in one line. See [$a, $b] = [$b, $a]. One line, huge impact!

#php #phptricks #codingtips #programmingtutorial #phparraydestructuring #listassignment #php7.1 #phpquiz #codingchallenge #phpshorts #phpmodern #variableassignment

https://www.youtube.com/watch?v=BCKs27NzXM4

PHP Array Destructuring Hack #codingtips

YouTube

PHP Empty String vs Zero

Watch this! PHP treats empty string and zero as falsy. See empty('') vs empty(0) vs empty('0'). The differences are INSANE!

#php #phptricks #codingtips #programmingtutorial #phpempty #falsyvalues #phpfunctions #phpquiz #codingchallenge #phpshorts #phpvalidation #truthyfalsy

https://www.youtube.com/watch?v=Z5z7MPhN07Y

PHP Empty String vs Zero #phpquiz

YouTube

Max of Arrays

Which array is bigger? Watch max([1,2,3], [4,5]) and learn how PHP compares arrays! The result is unexpected!

#php #phptricks #max #arrays #comparison #phpquiz

https://www.youtube.com/watch?v=3jXTBoFf0i8

Max of Arrays #phpquiz

YouTube

PHP Array Key Type Casting Mystery

Can you guess this? PHP array keys get cast automatically. Watch what happens with [1] vs ['1'] vs [true]. The result is wild!

#php #phptricks #codingtips #programmingtutorial #phparrays #arraykeys #typecasting #phpquiz #codingchallenge #phpshorts #arraybehavior #phpdata

https://www.youtube.com/watch?v=oBXSVMxoHBI

PHP Array Key Type Casting Mystery #phpquiz

YouTube

PHP Generator Yield Magic

Stop scrolling! PHP generators use memory efficiently. See function numbers() with yield. One keyword, infinite possibilities!

#php #phptricks #codingtips #programmingtutorial #phpgenerators #phpyield #memoryefficient #phpquiz #codingchallenge #phpshorts #phpadvanced #php5.5

https://www.youtube.com/watch?v=Tt0pvyS72VM

PHP Generator Yield Magic #codingtips

YouTube

PHP strcmp vs == Comparison

Stop scrolling! PHP strcmp() and == compare differently. See '10' vs '10.0'. The difference will shock you!

#php #phptricks #codingtips #programmingtutorial #phpstrcmp #stringcomparison #phpstrings #phpquiz #codingchallenge #phpshorts #stringfunctions #phpcomparison

https://www.youtube.com/watch?v=JNLjMPqfBZQ

PHP strcmp vs Comparison #phpstrcmp

YouTube

@gmazzap Although it is documented, the behavior of array_merge with integer keys is unexpected, since most people answered the question incorrect.

If you want to keep the keys when merging arrays, it is safer to use the + operator:

```php
$b = [4 => 1] + $a;
```

https://3v4l.org/42i4k#vnull

#phpquiz #php

array_merge vs + - created on 3v4l.org

View the output of this script on 3v4l.org: the online PHP shell with 250+ PHP versions