resource mysqli_connect ( [string server [, string username [, string password [, string database_name [, int port_number [, string socket]]]]]])
Switching to persistent connections in MySQL is simply a matter of changing your call mysqli_connect() so that the host name starts with "p:". For example, "p:localhost". The difference between the two is that standard connections will always open a new connection, whereas persistent connections will only open a new connection if there is not one already available.
Author's Note: In the per-process Apache module ("prefork"), persistent resources such as persistent MySQL connections are stored per process, which means if you have 150 Apache children running you'll need 150 MySQL permanent connections - even if some of those processes aren't using MySQL right now.
Want to learn PHP 7?
Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!