小编Col*_*lin的帖子

ereg/eregi替换PHP 5.3

我很抱歉提出一个问题,但在理解正则表达式代码时我没用.

在我没有编写的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所需的任何东西给我替换代码

php posix-ere eregi

16
推荐指数
2
解决办法
5万
查看次数

PHP变量保留在html代码中

如果我有类似下面的东西(非常基本,但我希望你明白我的意思)

.
. 
html code
.
.
<?php
$string=true;
.
.
?>
.
.
more html

.
.
<?php
if ($string)
.
.
?>
Run Code Online (Sandbox Code Playgroud)

假设页面尚未输出,那么$string仍然可以从之前获得该值还是必须<?php再次设置?

html php variables

0
推荐指数
1
解决办法
127
查看次数

标签 统计

php ×2

eregi ×1

html ×1

posix-ere ×1

variables ×1