PHP 7 Performance Check out our New PHP 7 Performance Infographic!
We’ve been benchmarking PHP 7 on Magento, Drupal, WordPress, Laravel and more — and the results are astounding! PHP 7 is blazing fast and you’re going to want to see these results. Check out the detailed performance benchmarks.
Category Archives: PHP
phpMyAdmin – Error You should upgrade to MySQL 5.5.0 or later
This is the second time that I get this error phpMyAdmin – Error You should upgrade to MySQL 5.5.0 or later.
We need to comment the following lines in libraries/common.inc.php.
#if (PMA_MYSQL_INT_VERSION < 50500) {
# PMA_fatalError(
# __('You should upgrade to %s %s or later.'),
# array('MySQL', '5.5.0')
# );
#}
PHP exec in background
So, in one of my projects/products/services, I need to execute ffmpeg via PHP…
Usually I use at do send the job to a queue list.. unfortunately in two different clients’ servers somehow PHP + exec and at doesn’t work well….
This is how we send a PHP exec to background
exec(command > /dev/null 2>/dev/null &);
header(‘HTTP/1.0 200 OK’) not working!
So, I had to force a script to set a 200 OK … otherwise Apache would set it a 404… due to RewriteEngine On bla bla bla…
So…
header('HTTP/1.0 200 OK')
Wasn’t working… but *everyone* says to use it that way!… ok…
I’v find out that the PHP version on my client server has a bug…
http://bugs.php.net/27026
So I had to set 299 OK.
This might not be the best solution I know…
PHP Browser language detection
This is how….
<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
case "pt":
echo "Browser lang PT!";
break;
case "it":
echo "Browser IT";
break;
case "en":
echo "Browser lang EN";
break;
default:
echo "Browser lang EN - Setting Default";
break;
}
?>
PHP – YYYY-MM-DD to Years Old
<?php
$birthDate = "1984-05-21";
$birthDate = explode("-", $birthDate);
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[2], $birthDate[1], $birthDate[0]))) > date("md") ? ((date("Y")-$birthDate[0])-1):(date("Y")-$birthDate[0]));
echo "Age is: ".$age;
?>
As seen on http://stackoverflow.com/questions/15341767/calculate-age-with-php-in-yyyy-mm-dd-format
Convert 00:00:00 time/lenght to 00h 00m in PHP
This is how!
$video_hours_exploded = explode(':', $stats['videosDuration']);
$video_hours = $video_hours_exploded[0].'h '.$video_hours_exploded[1].'m ';
PHP – 500 internal server error – cPanel
I’v been struggling for hours to solve a weird problem with PHP in a cPanel environment.
This is how my log (/usr/local/apache/logs/error_log) looks like
[Tue Dec 30 21:13:09 2014] [error] [client 88.94.5.xxx] SoftException in Application.cpp:601: Directory "/home/dee/subdomains/www2.domain.com/members" is writeable by group [Tue Dec 30 21:13:09 2014] [error] [client 88.94.5.XXX] Premature end of script headers: index.php [Tue Dec 30 21:13:09 2014] [error] [client 88.94.5.XXX] File does not exist: /home/dee/subdomains/www2.domain.com/500.shtml
I thought that was some bad configuration on .htaccess … but that was wrong!
On some environments we need to have the right file/directory permissions so it work…
- files: 644
- directories: 755
PHP Scan a dir and order by date – new first
This is how I’v made it
$photos = array_reverse(glob($_SERVER['DOCUMENT_ROOT'].'/photos/thumbs/*.{jpg,JPG,jpeg,gif,png}', GLOB_BRACE));
usort($photos, create_function('$b, $a', 'return filemtime($a) - filemtime($b);'));
PHP How to get the file extension
$path = $filename;
$ext = pathinfo($path, PATHINFO_EXTENSION);
You will get, for example .jpg
