Get entire URL including query string in PHP

<?php // Get current protocol. $protocol = stripos($_SERVER[‘SERVER_PROTOCOL’],’https’) === 0 ? ‘https://’ : ‘http://’; // Get current domain. $domain = $_SERVER[‘HTTP_HOST’]; // Get current path to the current file. $path = $_SERVER[‘SCRIPT_NAME’]; // Get current…

PHP | List all folders in the mailbox

$mbox = imap_open(“{mail.example.com:143/novalidate-cert}”, “foo@example.com”, “password”) or die(“can’t connect: ” . imap_last_error()); $folders = imap_list($mbox, “{mail.example.com:143/novalidate-cert}”, “*”); if ($folders === false) { echo “Failed to list folders in mailbox”; } else { print_r($folders); } imap_close($mbox);

MySQL – OPTIMIZE all tables with PHP and mysqli

$alltables = mysqli_query($conn, "SHOW TABLES"); while ($table = mysqli_fetch_assoc($alltables)){ foreach ($table as $db => $tablename){ echo "OPTIMIZE TABLE `".$tablename."`"; mysqli_query($conn, "OPTIMIZE TABLE `".$tablename."`") or die(mysqli_error()); echo "<br>"; } }

PHP – Replace last occurrence in a String

<?php function str_lreplace($search, $replace, $subject) { $pos = strrpos($subject, $search); if($pos !== false) { $subject = substr_replace($subject, $replace, $pos, strlen($search)); } return $subject; } $search = ".Maui"; $replace = "is awesome"; $subject = ".Maui .Maui";…

CSS Minify API 1.2 released!

We have just released a new version of the API to minimize CSS. Based on your feedback we have added four new parameters: removeurlquotes: Removes quotes from urls. Default is true.removecomments: Removes all comments. Default…