【发布时间】:2012-07-15 23:34:54
【问题描述】:
我有以下代码:
return preg_replace_callback("#\{gallery: '(.+?)'(?: dir: ([0-1]))?\}#i", create_function('$i', '$dir = isset( $i[2] ) ? 1 : 0; $oGallery = new Gallery( $i[1] ) ; $oGallery->PublicSide($dir);' ), $string);
问题是这适用于我的本地主机 (PHP5.3) 但是当我将它上传到我的服务器 (5.2.17) 时它没有.. 任何想法为什么?似乎与"#\{gallery: '(.+?)'(?: dir: ([0-1]))?\}#i"上的单引号有关
【问题讨论】:
-
定义“它不起作用”?函数调用返回什么?
-
它只返回完整的原始字符串,就好像在这种情况下它没有找到任何匹配项:{gallery: 'images/'} 或 {gallery: 'images/' dir: 1}
-
你阅读过这个函数的 PHP 文档吗?它的行为可能在 PHP 5.3 和 5.2.x php.net/manual/en/function.preg-replace-callback.php 之间有所不同
标签: php regex preg-replace-callback