(no commit message) master
authorChristian Weiske <cweiske@cweiske.de>
Tue, 29 Oct 2019 10:53:43 +0000 (11:53 +0100)
committerwww-cweiske <www-cweiske@ahso3>
Tue, 29 Oct 2019 10:53:43 +0000 (11:53 +0100)
safefloatstr.php [new file with mode: 0644]

diff --git a/safefloatstr.php b/safefloatstr.php
new file mode 100644 (file)
index 0000000..b58fb74
--- /dev/null
@@ -0,0 +1,18 @@
+<?php\r
+/**\r
+ * Cast variable to string.\r
+ * Floats get converted correctly without locale problems (always a dot)\r
+ *\r
+ * @param mixed $value\r
+ *\r
+ * @return string\r
+ */\r
+function safefloatstr($value)\r
+{\r
+    if (is_float($value)) {\r
+        return var_export($value, true);\r
+    }\r
+\r
+    return (string) $value;\r
+}\r
+?>
\ No newline at end of file