Conditionally declare hex2bin() due to a function of the same name being introduced in PHP 5.4
authorDan Fuhry <dan@enanocms.org>
Fri, 02 Dec 2011 01:15:55 -0500
changeset 1355 12c23b83c79d
parent 1354 eecde44145eb
child 1356 e80b5733ce9d
child 1365 a52cac1b190d
Conditionally declare hex2bin() due to a function of the same name being introduced in PHP 5.4
includes/functions.php
--- a/includes/functions.php	Sun Sep 18 02:13:34 2011 -0400
+++ b/includes/functions.php	Fri Dec 02 01:15:55 2011 -0500
@@ -1535,20 +1535,24 @@
 	return $ret;
 }
 
-/**
- * Converts a hexadecimal number to a binary string.
- * @param text string hexadecimal number
- * @return string
- */
-function hex2bin($text)
+if ( !function_exists('hex2bin') )
 {
-	$arr = enano_str_split($text, 2);
-	$ret = '';
-	for ($i=0; $i<sizeof($arr); $i++)
-	{
-		$ret .= chr(hexdec($arr[$i]));
-	}
-	return $ret;
+	/**
+	 * Converts a hexadecimal number to a binary string.
+	 * Enclose in an if(function_exists()) due to a builtin named hex2bin being added in PHP 5.4.x.
+	 * @param text string hexadecimal number
+	 * @return string
+	 */
+	function hex2bin($text)
+	{
+		$arr = enano_str_split($text, 2);
+		$ret = '';
+		for ($i=0; $i<sizeof($arr); $i++)
+		{
+			$ret .= chr(hexdec($arr[$i]));
+		}
+		return $ret;
+	}
 }
 
 /**