我很抱歉提出一个问题,但在理解正则表达式代码时我没用.
在我没有编写的php模块中是以下函数
function isURL($url = NULL) {
if($url==NULL) return false;
$protocol = '(http://|https://)';
$allowed = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)';
$regex = "^". $protocol . // must include the protocol
'(' . $allowed . '{1,63}\.)+'. // 1 or several sub domains with a max of 63 chars
'[a-z]' . '{2,6}'; // followed by a TLD
if(eregi($regex, $url)==true) return true;
else return false;
}
Run Code Online (Sandbox Code Playgroud)
某种善意的灵魂可以用替换eregi所需的任何东西给我替换代码
如果我有类似下面的东西(非常基本,但我希望你明白我的意思)
.
.
html code
.
.
<?php
$string=true;
.
.
?>
.
.
more html
.
.
<?php
if ($string)
.
.
?>
Run Code Online (Sandbox Code Playgroud)
假设页面尚未输出,那么$string仍然可以从之前获得该值还是必须<?php再次设置?