1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Configuring PHP settings in CLI
This guide explains how to configure PHP settings directly from the command line when running PHP scripts using PHP CLI (Command Line Interface). This can be useful when you need to temporarily modify certain settings for a specific script or PHP session.
Modifying PHP CLI Settings
To, for example, temporarily modify settings for a specific script without having to modify the global PHP configuration of the server, follow the method below; with the PHP CLI environment, you can specify multiple PHP settings at once by separating them with spaces.
Using the -d
parameter
When running PHP from the command line, you can use the -d
parameter to specify PHP configurations. This allows you to modify PHP settings for this specific execution. For example, to set the maximum execution time to 90 seconds, memory limit to 256 MB, and disable safe mode, you can do it as follows:
php -d max_execution_time=90 -d memory_limit=256M -d safe_mode=Off -f test.php