--- configure.orig
+++ configure
@@ -9840,14 +9840,14 @@
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PHP5 header files" >&5
 $as_echo_n "checking for PHP5 header files... " >&6; }
             case $PHP5 in
-        *5)
-          PHP5CONFIG=`echo "$PHP5"|sed 's/5$/-config5/'` ;;
+        *5*)
+          PHP5CONFIG=`echo "$PHP5"|sed 's/\(5.*\)$/-config\1/'` ;;
         *)
           PHP5CONFIG=$PHP5-config ;;
       esac
       php5_version=`$PHP5CONFIG --version 2>/dev/null`
       case $php5_version in
-      5*)
+      5.*)
         PHP5INC=`$PHP5CONFIG --includes 2>/dev/null`
         if test -n "$PHP5INC"; then
           { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PHP5INC" >&5
@@ -9942,7 +9942,7 @@
 $as_echo_n "checking for PHP header files... " >&6; }
             case $PHP in
         *7.*)
-          PHPCONFIG=`echo "$PHP"|sed 's/7\...*$/-config&/'` ;;
+          PHPCONFIG=`echo "$PHP"|sed 's/\(7.*\)$/-config\1/'` ;;
         *)
           PHPCONFIG=$PHP-config ;;
       esac
