Have you ever noticed developers putting backslashes (\) in front of their PHP function calls? It’s often referred to as a micro-optimization, but how could such a simple thing as a backslash improve the performance of your application? Introduced in PHP version 5.3, namespaces serve as a method to organize elements like classes and functions within an application.

Using tools like https://3v4l.org/, we can convert our function calls to opcode and see the difference with or without the backslash. Let’s start by calling a native PHP function from a namespace using a backslash prefix: namespace Foo\Bar; echo \strtoupper('Hello World'); op return operands --------------------------------- INIT_FCALL 'strtoupper' SEND_VAL 'Hello+World' DO_ICALL $0 ECHO $0
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners