First Steps in OOP in PHP: Essentials You Need to Know

I wrote a concise guide to OOP in PHP that walks you through classes and objects, inheritance, interfaces, all the way to exceptions. No philosophizing – just a factually correct foundation you can build on. For instance, right away in Nette.

Compilation errors in PHP: why are they still a problem?

PHP 7 tamed fatal errors into exceptions, but two hundred compile-time errors act as if it's still 2004. There's no way to catch them, php_check_syntax() was taken away from us after four minor versions, and the only option left is to call an external linter. I show how to do it – and what PHP 8.3 promises.

Why is the operator ?? sheer misfortune?

The ?? operator took 12 years to be born, arriving at the exact moment PHP stopped needing it. Instead of simplifying life, it now reliably conceals typos and bugs. I would have preferred if we had waited even longer for it.

Tabs Instead of Spaces as a Courtesy

The tabs vs. spaces debate has a thousand arguments on both sides, but one knocks them all to their knees: accessibility. A blind programmer on a 40-cell braille display wastes a quarter of the display because of your four spaces. Tabs aren't a preference – they're consideration.

Add the `{texy}` Tag to Latte

Texy 3.1.6 introduces the {texy} tag for Latte 3 – three lines of configuration and you're writing directly in Texy syntax in your templates. Static content is translated at compile time, dynamic content at runtime. I'll also show a trick with a custom callback function and passing parameters.

Latte 3: The Biggest Leap in Nette's History

For five years, I was afraid to take the plunge. A completely rewritten compiler, a custom PHP parser, an AST tree – not a single line of the original code remains. Latte now has the internals I've been dreaming about for eleven years.

Are You Just Following a Cargo Cult?

For twenty years I dutifully wrote static on constant properties and SCREAMED IN CAPS for constants, because “that's how it's done.” One stopped making sense sometime around PHP 7.3, the other never made sense in PHP at all. The bigger the nonsense, the deeper its roots.

Should nullable types be written with or without a question mark?

For years I refused to write the question mark for nullable types, because redundancy physically hurts me. Then PHP 8.0 came along with promoted properties and consistency forced me to capitulate. A story about how your own principles catch up with you.

Which Framework Has the Best Documentation?

How to objectively compare framework documentation? I measured the documentation-to-code ratio for seven major players. The result is surprisingly even – and that's actually the most interesting takeaway. Nette is above average and is the only one with a complete Czech translation.

How Shutdown and Destructor Calls Occur in PHP

Shutdown in PHP has its own ritual, and destructors play a role in it that few people understand correctly. Global objects are torn down in reverse order by a clever algorithm, while the rest only get a courtesy __destruct without actually being destroyed. And the best part saved for last: calling the destructor is not guaranteed at all.

That's all. More articles are on the way.

phpFashion © 2004, 2026 David Grudl | o blogu

Ukázky zdrojových kódů smíte používat s uvedením autora a URL tohoto webu bez dalších omezení.