Live data from Hacker News

Modern PHP Cheat Sheet

front-line-php.com

21–30 of 127 posts

Re: Modern PHP Cheat Sheet

#21
post #18

Earlier quoted context omitted.

I personally think it looks broken and wrong. For short strings I don't see the point and for multiline strings, use a heredoc.

The reason I never use Heredoc is because you need to abandon your indentation, otherwise your tabs/spaces get included in the string. Is there a way around that?

I thought they fixed this with [1] Flexible Heredoc in 2017 with PHP 7.3

[1] https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes

Re: Modern PHP Cheat Sheet

#23

The comment on Numeric values is misleading: > Use the _ operator to format numeric values: > $price = 100_10; > // $100 and 10 cents Makes it sound like the underscore replaces the decimal, which it doesn't. The underscores are simply ignored by the PHP parser, so that 10_0.1 === 1_00.1. You could afterwards use PHP to replace the `_` with a comma for display purposes, and I assume that is what they are trying to sa…

Yeah, that's a terrible example since some places do use comma as a dollars/cents separator, and others don't. And some people use floats for currency (with the obvious caveats), and might read this as "_ is the same as a decimal point".

They really should just use a simpler example, like 10_000_000 being easier to read as "10 million" than 10000000.

Re: Modern PHP Cheat Sheet

#25
post #12

As a solo bootstrapped founder working on PHP (Laravel) every day, I was surprised to learn a LOT from this one page. Thanks for posting.

The guys behind it work at Spatie[1] which you have probably heard of some of their packages, and Freek has a blog[2] that has a lot of PHP stuff on - lots Laravel, and lots just general new language stuff (covering PHP8 features etc)

[1] https://spatie.be [2] https://freek.dev

Re: Modern PHP Cheat Sheet

#26
I'm using Laravel/PHP for a new project and it's been a joy. A true joy. After spending the last 6+ years writing backend services in Node, PHP feels like a breath of fresh air. No restarting the server, no compiling errors from babel/typescript wackiness, no blocking threads, server-side templates out-of-the-box, and so much more.

PHP has come a really long way, I really hope to see it's resurgence some day after everyone has been burned enough from running JavaScript as their server.

Re: Modern PHP Cheat Sheet

#27

The choice of colors for this page makes it really difficult to read

You should probably edit (in this case) the 'bg-blue-300' class in your broswer's "developer's tools".

Some of us edit the styles as normal practice for a large number of sites, especially after the widespresad use of thin fonts, grey text etc.

Surely there will also be tools (add-ons) to replace css elements as needed per domain...

Re: Modern PHP Cheat Sheet

#28
The evolution of PHP has shown the difference that having engaged stewards of the language can make. Saw a list of quotes[1] from Rasmus Ledorf which I think explains it's stagnation. As someone who used to sneer at the language, modern PHP doesn't look out of place among Ruby, Python, etc.

https://mobile.twitter.com/woketopus/status/1447150924846313...

Re: Modern PHP Cheat Sheet

#29

The choice of colors for this page makes it really difficult to read

The use of ligatures in the code examples also isn't helpful for people not familiar with the syntax.

You mean '=>' becoming as if ⇒ (U+D1D2)? Yes, it gives you a moment of "Mh?!".

Re: Modern PHP Cheat Sheet

#30
post #4

Earlier quoted context omitted.

I also find the super slim scrollbar difficult to use.

Is there some browser flag that disables custom scrollbars? Surely its a problem for accessibility.

In Firefox's about:config you can set layout.css.scrollbar-width.enabled to false.
Post reply on HN