summaryrefslogtreecommitdiff
path: root/Zend/tests/closure_047.phpt
diff options
context:
space:
mode:
authorMarcel Araujo <ceceldada@gmail.com>2013-06-21 23:08:15 -0300
committerStanislav Malyshev <stas@php.net>2013-08-18 15:18:30 -0700
commit265224778bc340b16087e60a52b4ca4a3acb5c01 (patch)
treec9f86d4969c93e468ee6a6bda9faade7e045987c /Zend/tests/closure_047.phpt
parent47678c06c65be8cd844b1d6ee61f7645e0f9bfcf (diff)
downloadphp-git-265224778bc340b16087e60a52b4ca4a3acb5c01.tar.gz
Use in preg_replace_callback() using variables by reference and test for bug #64979
Diffstat (limited to 'Zend/tests/closure_047.phpt')
-rw-r--r--Zend/tests/closure_047.phpt26
1 files changed, 26 insertions, 0 deletions
diff --git a/Zend/tests/closure_047.phpt b/Zend/tests/closure_047.phpt
new file mode 100644
index 0000000000..2377bef6b7
--- /dev/null
+++ b/Zend/tests/closure_047.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Closure 047: Use in preg_replace_callback() using variables by reference
+--FILE--
+<?php
+
+function replace_variables($text, $params) {
+
+ preg_replace_callback( '/(\?)/', function($matches) use (&$params, &$text) {
+
+ $text = preg_replace( '/(\?)/', array_shift( $params ), $text, 1 );
+
+ }, $text );
+
+ return $text;
+}
+
+echo replace_variables('a=?', array('0')) . "\n";
+echo replace_variables('a=?, b=?', array('0', '1')) . "\n";
+echo replace_variables('a=?, b=?, c=?', array('0', '1', '2')) . "\n";
+echo "Done\n";
+?>
+--EXPECT--
+a=0
+a=0, b=1
+a=0, b=1, c=2
+Done