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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners