Cheat Sheets
Agile
Containers
DevOps Automation
DevOps Linux
DevOps Services
Glib Examples
Go Examples
Javascript Examples
Languages
PHP Examples
Python Examples
Scripting
Security
Solutions
Virtualization
visual-ops
Apache
CouchDB
Couchbase
ElasticSearch
Eureka
F5
GlusterFS
Hadoop
Java
Kafka
MongoDB
MySQL
NFS
Nodejs
PgBouncer
Postgres
RabbitMQ
Redis
Squid
Tomcat
Webserver
Zookeeper
etcd
htaccess
htaccess Checker
memcached
nginx
sqlite
zuul
AWS - CLI
AWS - Cost
Deis
EC2 API Tools
ESX
Flynn
Heroku
Juju
KVM
LXC
LXD
OpenNebula
OpenStack
OpenVZ
VM Tuning
Vagrant
Vagrantfile
VirtualBox
Xen
heroku
systemd
vSphere
PyGI GStreamer
PyGI GTK Tutorial
PyGI GnomeKeyring
PyGI GtkStatusIcon
PyGObject API
Python Sockets
Python Syntax
Python re.match
Python re.sub
Python simplehttpserver
Python subprocess
Ansible
Bower
Chef
Gerrit
Git
Hubot - Howto
IT-Ops
Jenkins
Maven
Mcollective
Monitoring
Packaging
Puppet
Puppet - Hiera
Puppet - Iterating
Splunk
cfengine
salt
saltstack
CSS
Dev-Misc
GCC
GraphQL
JSON Schema
JSON
Java Debugging
Javascript
Linting
Linux HTML Widgets
Markdown
PHP
Perl
Perl Regex
Python
Regex Overview
Regex101
Ruby
Ruby Bundler
Ruby Regex
SVG Attributes
SVG Elements
Syndication
XHTML
XML 1.0
XML 1.1
XPath
XSD
XSLT 2.0
YAML
autotools
gdb
rvm
Go Channels
Go Goroutines
Go Interfaces
Go Struct
PHP Arrays
PHP curl_setopt
PHP date
PHP explode
PHP implode
PHP ini_set
PHP preg_match
PHP preg_replace
PHP str_replace
PHP stripos
PHP strpos
PHP strripos
PHP strrpos
PHP ternary operator
PHP unserialize
APIs
Bash
Bash Associative Array
Bash Functions
Bash Regex
Color Distance
Shell Problems
Shell-Scripting
awk
packages.json
sed
DBUS
DKMS
DRBD
Debian
Debugging
Filesystem
GPG
IPMI
Kernel Tracing
LVM
Linux Insides
Linux-Commands
Linux-HA
Linux-Networking
Linux-Sysadmin
Linux-Virtualization
Mail
Package Management
Packaging
Partitioning
Quota
RAID
SSH
Solaris
SysRq
Sysctl - Net
UEFI Install
ffmpeg
jq
screen-vs-tmux
sssd
systemd
ulimit
vi
vi - Advanced
Glib
Glib GRegex
Glib Testing
Glib XDG Migration
Docker
Helm
Openshift
kubernetes
rkt
Availability Data
Free Tier Compilation
SaaS Dev Tools
Solutions Automation
Solutions Monitoring
Solutions NoSQL
Solutions Virtualization
Status Pages
Agile Roles
Depth of Kanban
Kanban - Kaizen
Scrum
Scrumban
Semantic Services
Team of Teams
Neighbourhood Network
netstat Dendrogram
netstat Force Graph
netstat Services
AppArmor
HTTPS
Nmap
OpenSSL
Package Vulnerabilities
SELinux
SIEM
SSL-Certificates
Secure REST APIs
Security Auditing
Security-News-Feeds
Session Mgmt
Unhide Processes
Dependency Test
Javascript Singleton
Javascript strptime
Javascript toggle visibility
Javascript void0
Nodejs Compatibility
Nodejs Express
React
React JSX
React PropTypes
React Tutorial
Todo MVC

PHP ini_set Examples

Syntax of ini_set()

The ini_set() syntax is simple:
string ini_set ( string $varname , string $newvalue )
it is just a key value setter. The important question is which values can be set. Below you find a list of working examples. Please note that you cannot change all php.ini options especially those that need to be set before PHP initializes.

Useful Working ini_set() Examples

1. Enabling error display

On production sites you typically do not show errors in the page for usability and security reasons. But when you when you debug something live you might want to enable it temporarily and just for you:
# Assuming 5.44.33.22 is your IP...
if ( $_SERVER["REMOTE_ADDR"] == "5.44.33.22") {
    ini_set('display_errors', '1');
}
Note: you may want to combine this with
error_reporting(E_ALL | E_STRICT);

2. Changing Memory Limit

When you need to increase memory from within the code:
ini_set("memory_limit","1000M");
Note though that this might be prevent by a Suhosin hardended PHP installation.

3. Adding include paths

Normally this shouldn't be necessary. It is way cleaner to do it in php.ini, but if you bundle libraries and you administrator doesn't know:
<?php ini_set('include_path',ini_get('include_path').':../my-libs:');  ?>

When You Cannot Use ini_set()

For most php.ini settings you can't use ini_set(). To workaround consider deploying a .htaccess along with your code as this .htaccess can provide all PHP options to overwrite the default php.ini settings. For example to change the HTTP POST limit add this line to a .htaccess read by your webserver:
php_value post_max_size 2500000
Note how the "php_value" prefix indicates settings for PHP. So simple syntax is
php_value <key name> <value>
Comment on Disqus





Related pages