PHP can be configured using:
php.ini file – The main configuration file for PHP.phpinfo() function – Displays current PHP configuration.Finding php.ini
C:\xampp\php\php.ini/etc/php/8.1/apache2/php.ini (version may vary)/Applications/MAMP/bin/php/php7.x.x/conf/php.iniYou can find the loaded php.ini file using PHP:
<?php phpinfo(); ?>
php.ini.1️⃣ Display Errors
display_errors = On ; Show errors in browser (useful for development) display_startup_errors = On error_reporting = E_ALL
2️⃣ Maximum File Upload Size
upload_max_filesize = 10M post_max_size = 20M
upload_max_filesize → Maximum single file sizepost_max_size → Maximum size for entire form submission3️⃣ Timezone Setting
date.timezone = "Asia/Kolkata"
"Asia/Kolkata" with your timezone (see PHP manual for full list).4️⃣ Maximum Execution Time
max_execution_time = 30 ; seconds
5️⃣ Memory Limit
memory_limit = 128M
6️⃣ Extensions
Enable extensions by removing ; before the line in php.ini:
extension=mysqli extension=curl
Using phpinfo()
<?php phpinfo(); ?>
Using ini_get() and ini_set()
<?php
// Get current value
echo ini_get('max_execution_time'); // 30
// Change value at runtime
ini_set('max_execution_time', 60);
echo ini_get('max_execution_time'); // 60
?>
Note: Changes with ini_set() last only for the current script.php.ini – Permanent change.htaccess file (Apache only) – Temporary change for a directory:php_value upload_max_filesize 20M php_value post_max_size 25M
ini_set() – Temporary for a scriptdisplay_errors = On for devdisplay_errors = Off for live siteexec, shell_exec, etc.file_uploads and open_basedir.memory_limit and max_execution_time for heavy scripts.OPcache.<?php
echo "<h2>PHP Configuration</h2>";
// PHP Version
echo "PHP Version: " . phpversion() . "<br>";
// Max Execution Time
echo "Max Execution Time: " . ini_get('max_execution_time') . " seconds<br>";
// Memory Limit
echo "Memory Limit: " . ini_get('memory_limit') . "<br>";
// Check if mysqli extension is loaded
if(extension_loaded('mysqli')){
echo "MySQLi extension is enabled.";
} else {
echo "MySQLi extension is not enabled.";
}
?>
This script displays:
✅ Key Points:
php.ini is the main configuration file for PHP.phpinfo() to check current settings.display_errors, upload_max_filesize, memory_limit, timezone.ini_set() or .htaccess for script-specific adjustments.<br />
<b>Deprecated</b>: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in <b>/home/voksinst/tutorials.voksinstitute.com/admin/topics.php</b> on line <b>265</b><br />