草庐IT

MATCH_PARENT

全部标签

php - preg_match : ensure the start and the end contains something

我想要一个正则表达式来确保字符串的开头包含“http://”和“/”以及结尾。这是我想出的一个更长的版本,if(!preg_match("/(^http:\/\//",$site_http)){$error=true;echo'';}elseif(!preg_match("/\/$/",$site_http)){$error=true;echo'';}但我认为这两个表达式可以像下面这样放在一起,但它行不通,if(!preg_match("/(^http:\/\/)&(\/$)/",$site_http)){$error=true;echo'';}我尝试组合的多个表达式一定是错误的!有什

PHP 5.2 preg_match() 编译失败

非常感谢一些帮助。我的主机服务器端更新导致我的评论表单抛出两个验证错误。第一个是:preg_match()返回警告:preg_match()[function.preg-match]:编译失败:[脚本位置和行错误]中偏移量13处字符类中的范围乱序-第二个是主题检查偏移量14。它在电子邮件地址检查中执行此操作:if(preg_match('/[^a-zA-Z0-9_-.]/',$_POST['txtEmail']))和主题检查:if(preg_match('/[^a-zA-Z0-9:?-.]/',$_POST['txtSubject']))我不熟悉PHP,但可以剪切和粘贴!我的网站是fr

php - Wordpress 通过 child ID 获取当前过期 parent

在页面中我有学期child的ID,我需要通过childID找出这个child的parent,这是可以接受的,也许有人可以帮助解决这个问题? 最佳答案 这就是get_term的内容功能用于:$term_id=21;//Luckynumber:)$child_term=get_term($term_id,'category');$parent_term=get_term($child_term->parent,'category');将'category'替换为您正在使用的任何分类法。 关于

php - preg_match 查找并替换字符串模式

我有一个wordpress数据库,其中有一些来自soundcloud的嵌入式iframe。我希望将iframe替换为某种简码。我什至创建了一个简码,效果非常好。问题是我有一个旧数据库,其中包含大约2000个已经嵌入代码的帖子。我想做的是编写一个代码,以便用短代码替换iframe。这是我用来从内容中查找url的代码,但它总是返回空白。$string='ThinkKavinskymeetsFuturecop!meetsyourfavorite80sTVshowthemesongandyoumightbeprettyclosetoSwedishproducerJohanBengtsson\'

php - WordPress 主题 "ERROR: The theme defines itself as its parent theme. Please check the Template header."

在我的WordPress网站的主题区域中,我收到一条奇怪的消息-“错误:主题将自己定义为其父主题。请检查模板标题。”我无法弄清楚什么是错的。请帮我。header.php文件代码如下:"/>/Images/favicon.gif"/>/Font/font-awesome-4.0.3/css/font-awesome.min.css">">"height="height;?>"width="width;?>"alt="fortuneshop9999"/>functiongoogleTranslateElementInit(){newgoogle.translate.TranslateEle

php - preg_match 表现得很奇怪

我正在使用preg_match()从变量中提取文本片段,假设变量如下所示:[htmlcode]Thisissupposedtobedisplayed[/htmlcode]middletext[htmlcode]Thisisalsosupposedtobedisplayed[/htmlcode]我想提取[htmlcode]的内容并将它们输入到一个数组中。我通过使用preg_match()来做到这一点。preg_match('/\[htmlcode\]([^\"]*)\[\/htmlcode\]/ms',$text,$matches);foreach($matchesas$value){r

php - 不使用 preg_match() 在 PHP 中进行 UTF-8 验证

我需要验证一些以UTF-8编码的用户输入。许多人推荐使用以下代码:preg_match('/\A([\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*\z/x',$string);这是一个取自http

php - 扩展 PDO 的类 - parent::__construct 不起作用,但创建新的 PDO 可以

我正在尝试编写一个PDO包装器,但我在构造函数方面遇到了一些问题。理想情况下,我想调用父级的构造函数,但由于某种原因,这是行不通的。我尝试(测试)检查是否创建了一个新的PDO并且确实有效,我发现这最令人困惑。这是我的代码:classdbextendsPDO{private$dbconn;publicfunction__construct(){$dsn='mysql:dbname='.MYSQL_DB.';host='.MYSQL_HOST;$user=MYSQL_USER;$pw=MYSQL_PW;try{$this->dbconn=parent::__construct($dsn,$

PHP - preg_match 和 "Unknown modifier"错误

这个问题在这里已经有了答案:Warning:preg_replace():Unknownmodifier(3个答案)关闭3年前。我的测试运行良好:if(ereg("([0-9]{2})[-./]([0-9]{2})[-./]([0-9]{4})[]([0-9]{2}):([0-9]{2}):([0-9]{2})",$dateToTest,$tab)==false)由于ereg已被弃用,我用这个替换了那个测试:if(preg_match("/([0-9]{2})[-./]([0-9]{2})[-./]([0-9]{4})[]([0-9]{2}):([0-9]{2}):([0-9]{2})

php - preg_match 只允许字母、空格和破折号和空格

我知道如果$stringabc包含除数字以外的任何内容,我当前使用的一个条件是:if(preg_match("/[^0-9]/",$stringabc))我想要一个if条件,如果$stringdef包含除字母、空格和破折号(-)以外的任何内容,它会给出错误。 最佳答案 那就是:if(preg_match('/[^a-z\s-]/i',$stringabc))“除字母(a-z)、空格(\s,表示任何类型的空格)和破折号(-)之外的任何内容”。也允许数字:if(preg_match('/[^0-9a-z\s-]/i',$stringab