我正试图用一个空格替换多个空格.当我使用时ereg_replace,我收到一个关于它被弃用的错误.
ereg_replace("[ \t\n\r]+", " ", $string);
Run Code Online (Sandbox Code Playgroud)
是否有相同的替代品.我需要用一个" "空格替换多个空格和多个nbsp空格.
我有以下错误:
警告:preg_replace():第38行的xxx.php中的未知修饰符']'
这是第38行的代码:
<?php echo str_replace("</ul></div>", "", preg_replace("<div[^>]*><ul[^>]*>", "", wp_nav_menu(array('theme_location' => 'nav', 'echo' => false)) )); ?>
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗?
示例用户输入
http://domain.com/
http://domain.com/topic/
http://domain.com/topic/cars/
http://www.domain.com/topic/questions/
Run Code Online (Sandbox Code Playgroud)
我想要一个PHP函数来使输出像
domain.com
domain.com/topic/
domain.com/topic/cars/
www.domain.com/topic/questions/
Run Code Online (Sandbox Code Playgroud)
让我知道 :)
我写了以下PHP代码:
$input="menu=1&type=0&";
print $input."<hr>".ereg_replace('/&/', ':::', $input);
Run Code Online (Sandbox Code Playgroud)
运行上面的代码后,它会发出以下警告:
不推荐使用:不推荐使用函数ereg_replace()
我该如何解决此警告.
可能重复:
将ereg表达式转换为preg
<?php
$searchtag = "google";
$link = "http://images.google.com/images?hl=de&q=$searchtag&btnG=Bilder-Suche&gbv=1";
$code = file_get_contents($link,'r');
ereg("imgurl=http://www.[A-Za-z0-9-]*.[A-Za-z]*[^.]*.[A-Za-z]*", $code, $img);
ereg("http://(.*)", $img[0], $img_pic);
echo '<img src="'.$img_pic[0].'" width="70" height="70">'; ?>
Run Code Online (Sandbox Code Playgroud)
我得到这个错误
不推荐使用:函数ereg()在第5行的C:\ Program Files\EasyPHP-5.3.8.1\www\m\img.php中已弃用
不推荐使用:函数ereg()在第6行的C:\ Program Files\EasyPHP-5.3.8.1\www\m\img.php中已弃用
preg_match()函数给出了这个错误
警告:preg_match()[function.preg-match]:在第6行的C:\ Program Files\EasyPHP-5.3.8.1\www\m\img.php中,分隔符不能是字母数字或反斜杠
警告:preg_match()[function.preg-match]:在第7行的C:\ Program Files\EasyPHP-5.3.8.1\www\m\img.php中,分隔符不能是字母数字或反斜杠
可能重复:
如何在PHP中将ereg表达式转换为preg?
我需要帮助,下面是一个很小的非常基本的正则表达式,有点验证一个电子邮件,我确实认为它不是最好的工作,但我的需求现在还可以.
它目前使用PHP的eregi函数,php.net说它现在是折旧函数,我应该使用preg_match,只需用preg_match替换erei不起作用,有人可以告诉我如何让它工作吗?
function validate_email($email) {
if (!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $email)) {
echo 'bad email';
} else {
echo 'good email';
}
}
function validate_email($email) {
if (!preg_match("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $email)) {
echo 'bad email';
} else {
echo 'good email';
}
}
Run Code Online (Sandbox Code Playgroud) 有人知道弃用的eregi_replace函数的一个很好的替代品吗?
我需要它为这个片段:
$pattern = "([a-z0-9][_a-z0-9.-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})";
$replace = "<a href=\"mailto:\\1\">\\1</a>";
$text = eregi_replace($pattern, $replace, $text);
Run Code Online (Sandbox Code Playgroud)
谢谢!
我很抱歉提出一个问题,但在理解正则表达式代码时我没用.
在我没有编写的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所需的任何东西给我替换代码
我两年前偶然发现了这个问题.
有没有办法在预准备语句上调用PDOStatement :: execute()时获取原始SQL字符串?出于调试目的,这将非常有用.
获胜的答案说明了这一点
[...]如果设置PDO属性PDO :: ATTR_EMULATE_PREPARES,您也可以获得所需的内容.在此模式下,PDO将参数插入到SQL查询中,并在执行()时发送整个查询.
但它没有提到如何获得结果查询字符串.我知道这是一个糟糕的主意,但在调试模式下这并不会让我感到困扰.有人知道怎么做这个吗?
PS如果有某种方式我可以重新开放/引起对原来两年前主题的关注,而不是打开一个新主题,请告诉我.
我正在尝试向数据库提交值,但我收到一条错误消息
不推荐使用:函数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) php ×10
regex ×3
deprecated ×2
ereg ×2
eregi ×2
function ×2
posix-ere ×2
preg-replace ×2
email ×1
ereg-replace ×1
formatting ×1
pcre ×1
pdo ×1
preg-match ×1
wordpress ×1