我很抱歉提出一个问题,但在理解正则表达式代码时我没用.
在我没有编写的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所需的任何东西给我替换代码
我正在尝试向数据库提交值,但我收到一条错误消息
不推荐使用:函数eregi()在第20行和第27行的C:\ wamp\www\OB\admin_add_acc.php中已弃用
这是代码:
<?php
include 'db_connect.php';
if(isset($_POST['Submit']))
{
$acc_type=ucwords($_POST['acc_type']);
$minbalance=ucwords($_POST['minbalance']);
if (!eregi ("^[a-zA-Z ]+$", stripslashes(trim($acc_type))))//line 20
{
echo "Enter Valid Data for Account Type!";
exit(0);
}
else
{
if (!eregi ("^[0-9 ]+$", stripslashes(trim($minbalance))))//line 27
{
Run Code Online (Sandbox Code Playgroud) 函数eregi()已弃用.我怎样才能取代eregi().我尝试使用preg_match然后停止工作.
我们帮助他们:
http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php
代码之前:
if ( ! eregi("convert$", $this->library_path))
{
if ( ! eregi("/$", $this->library_path)) $this->library_path .= "/";
$this->library_path .= 'convert';
}
if (eregi("gd2$", $protocol))
{
$protocol = 'image_process_gd';
}
Run Code Online (Sandbox Code Playgroud)
代码然后:
if ( ! preg_match("convert$/i", $this->library_path))
{
if ( ! preg_match("/$/i", $this->library_path)) $this->library_path .= "/";
$this->library_path .= 'convert';
}
if (preg_match("gd2$/i", $protocol))
{
$protocol = 'image_process_gd';
}
Run Code Online (Sandbox Code Playgroud) 我有一个算法,给出一个带小数点的数字(IE".57").我想做的就是得到没有小数的"57".
我用过eregi_replace和str_replace都没用过!
$one = ".57";
$two = eregi_replace(".", "", $one);
print $two;
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何在PHP中将ereg表达式转换为preg?
我的联系表格是其他工作,但我一直收到以下错误:
不推荐使用:函数ereg()在/ home/.....中已弃用
我真的迷失了,但我认为这是需要调整的部分.
if ( empty($_REQUEST['name']) ) {
$pass = 1;
$alert .= $emptyname;
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['name'] ) ) {
$pass = 1;
$alert .= $alertname;
}
if ( empty($_REQUEST['email']) ) {
$pass = 1;
$alert .= $emptyemail;
} elseif ( !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z] {2,3})$", $_REQUEST['email']) ) {
$pass = 1;
$alert .= $alertemail;
}
if ( empty($_REQUEST['message']) ) {
$pass = 1;
$alert .= $emptymessage;
} elseif ( preg_match( "[][{}()*+?\\^$|]", $_REQUEST['message'] ) ) {
$pass …Run Code Online (Sandbox Code Playgroud) 我需要更改150多个PHP文件(将ereg更新为preg_match).我厌倦了手动更新它们但它需要永远,我想确保我的所有替换将第一次工作.我该怎么做才能做这种操作?
这是我的ereg(i)的一些例子
if(eregi("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $ip)) { /* ... */}
if (eregi($regexp, $label, $match)) { /* ... */}
$string = eregi_replace("[[:space:]]+", ' ', $string);
Run Code Online (Sandbox Code Playgroud)
谢谢
所以,我在我的邮件脚本中使用了eregi,但是最近,我得到了该函数被弃用的错误.
那么,替换以下代码的最简单方法是什么:
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email'])))?
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏:)
我使用的是PHP 5.3.0,我使用wamp服务器功能就是这样
eregi("^[ \f\r\t\n]{0,}(SELECT){1}(.+)$",$this->ss_last_query)
eregi("^[ \f\r\t\n]{0,}(UPDATE|INSERT|DELETE){1}(.+)$",$this->ss_last_query)
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何在PHP中将ereg表达式转换为preg?
我如何将此代码转换为php 5.3:
if (eregi("VERIFIED",$this->ipn_response)) { }
Run Code Online (Sandbox Code Playgroud) 我一直在阅读和阅读正则表达式,但我无法弄清楚我的代码有什么问题:
if(eregi("^[A-Za-z0-9_\-]$", $username)){return true;}
Run Code Online (Sandbox Code Playgroud)
它永远不会回归真实.我正在尝试验证用户名,并且只允许使用小写az,大写az,数字,连字符和下划线.
在PHP 5.3.8上运行时出现以下错误
不推荐使用:函数eregi_replace()在第49行的/home/XXXXXX/public_html/admin/modifypoll.php中已弃用
这是代码行,任何人都可以帮忙
$question = eregi_replace('</?[a-z][a-z0-9]*[^<>]*>', '', $question );
Run Code Online (Sandbox Code Playgroud)
我不知道该改变什么.任何人都可以帮忙
eregi ×11
php ×11
deprecated ×3
regex ×3
replace ×2
decimal ×1
ereg ×1
expression ×1
forms ×1
function ×1
posix-ere ×1
preg-match ×1
validation ×1