preg_split() splits #PHP strings with regexes, captures the separators and can handle an empty regex.

You don't need that everyday, but when you do, #PHP has it!

#phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/preg_split.html

#[ReturnTypeWillChange] works on native #PHP methods and also on custom ones.

#phptrick #phptip

https://php-tips.readthedocs.io/en/latest/tips/returntypewillchange_for_all.html

ReturnTypeWillChange Is For All

``ReturnTypeWillChange`` is an attribute that tells PHP that the return type of the related method is different from the defined by the PHP native methods

#PHP's NAN is 0 as an integer, 'NAN' as a string and not comparable with itself.

Also, there are now warning when using them, so no one can get hurt by this.

#phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/compare_nan.html

Enumerations are backed by strings, they work with in_array(), but not with array_unique()

Well, at least, not directly.

Also, did you know Enum::cases() ?

#phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/array_unique_and_enum.html

#PHP puzzle of the day: can you make Chidren::foo() call GrandParents::foo() ?

Think about it, and then, click below for the solution(s).

#phptip #phptrick

https://www.exakat.io/calling-all-ancestors/

Would it be cool to have a #PHP ::parent operator, like we have the ::class operator

Well, turns out we can.

#phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/parent_operator.html

Can you make this #PHP riddle running?

This compiles, so you can only add more code to make it work.

I asked 5 AI, 2 succeeded, 3 failed.

#phptip #phptrick

So, #PHP typed class constants are vaguely useful?

Here is a nice usage case that will definitely makes everyone love them.

#phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/crazy_const_type.html

#PHP numeric separator works well on integer, floats and also hexadecimals, octals and ... binary. And most useful in the latter, right?

0b1111_00_111_101_111

#phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/hexadecimal_separator.html