PHP
PHP is the server-side language behind WordPress, Laravel, and many other sites. A visitor's browser never runs PHP; the server executes the script and returns the HTML it produces. On each request the interpreter reads the file, parses it into bytecode, and runs that bytecode to build the output. Without OPcache, the parsing step happens all over again on every request. The time PHP spends per request also drives limits like Entry Processes on shared hosting.
Choosing the PHP version
On a hosting account the version is usually set per domain through cPanel's MultiPHP Manager, not as one value for the whole account. Your main site can run PHP 8.3 while an older project stays on 8.1 until it is compatible. After a switch, test login, forms, checkout, and wp-admin, then read the error log if the site returns an HTTP 500. Over SSH, php -v reports the CLI version, and the CLI can differ from the version the web handler uses. That gap bites when you run WP-CLI commands.
Where directives go
Directives such as memory_limit, max_execution_time, upload_max_filesize, post_max_size, and display_errors can live in several places. On a server you own, use php.ini. Under PHP-FPM or CGI, drop a .user.ini in the site folder, or use php_value in .htaccess only when the handler is Apache mod_php. Writing php_value memory_limit 256M into .htaccess while the site runs on PHP-FPM brings every page down with a 500, because FPM refuses that directive. Most panels also ship a MultiPHP INI Editor to change directives per domain without touching files. Keep display_errors off in production so error details do not leak to visitors.
Confirming the effective value
Do not guess which file the handler reads. Check phpinfo(), or query the CLI:
php -i | grep memory_limit
Compare the CLI number with the web number; when they differ, you are looking at two separate configs. php -m lists loaded modules, which helps you confirm an extension is active before blaming the code.
Version jumps and directive edits fail differently
Switching PHP versions and editing directives fail in opposite ways. A new version can trigger fatal errors on old code, so the site breaks loudly and you know to roll back. A directive placed in the wrong file fails quietly: the site keeps running on the default value, and the symptom is a big upload that dies or a script that times out for no visible reason. Treat a version change as an event you test, and a directive change as a change you verify.
FAQ
Does memory_limit mean more storage?
No. memory_limit is the RAM ceiling for one PHP process, not a disk quota. It caps how much memory a single script may use, and raising it does not add storage space.
Can I set PHP directives in .htaccess?
Only if the handler is Apache mod_php. Under PHP-FPM or CGI, php_value in .htaccess causes a 500. Use .user.ini or the panel's INI editor instead.
My site broke after a PHP switch, what first?
Roll back to the last stable version, then find the plugin or theme that errors before trying the upgrade again. Do not force a new version on a site that will not open.
Disclaimer: Hosting Wiki articles are prepared for educational and reference purposes. Hosting technology keeps evolving, so some technical details may change over time.