草庐IT

not_matched

全部标签

php - 约会的 Preg_match

我正在尝试使用preg_match在PHP中匹配一个日期,拆分它并将它的一部分分配给一个数组,日期看起来像“20100930”,这是我正在使用的代码://Makethetor_fromdatelooknicer$nice_from=$_POST['tor_from'];$matches=array();$ideal_from='';preg_match('/\d{4}\\d{2}\\d{2}\/',$nice_from,$matches,PREG_OFFSET_CAPTURE,0);//if(isset($matches[0]))$nice_from=$matches[0];echo$

php preg_match 验证价格格式

我想验证我表单中的数字字段(价格)。我尝试以这种方式验证像10.00这样的格式,没问题。$pattern='/^\d+(:?[.]\d{2})$/';if(preg_match($pattern,$_POST['price'])=='0'){echo"ERROR";exit;}现在我想同时验证字段格式,例如10.00和10。我怎么能这样做? 最佳答案 你的新模式:$pattern='/^\d+(\.\d{2})?$/';将验证:1010.00如果您想使以零开头的数字无效,例如05.00,以下模式会有所帮助:$pattern='/^(

php - ' fatal error : Class 'CURLFile' not found' error in Facebook PHP Application for 'upload photo to user' s timeline'

我刚刚尝试使用FacebookPHPSDK开发一个Facebook应用程序。Facebook开发者网站中给出的示例代码如下。'YOUR_APP_ID','secret'=>'YOUR_APP_SECRET','fileUpload'=>true,'allowSignedRequest'=>false//optionalbutshouldbesettofalsefornon-canvasapps);$facebook=newFacebook($config);$user_id=$facebook->getUser();$photo='./mypic.png';//Pathtothepho

php - 为什么 preg_match_all 返回两个匹配项?

我正在尝试使用preg_match_all来确定一个字符串是否在双引号之间有任何单词,但是它是重复的结果,第一个结果的两边都有两组双引号,其中作为被搜索的字符串只有一套。这是我的代码:$str='Teststart."Testmatchthis".Testend.';$groups=array();preg_match_all('/"([^"]+)"/',$str,$groups);var_dump($groups);然后vardump产生:array(2){[0]=>array(1){[0]=>string(17)""Testmatchthis""}[1]=>array(1){[0]

php - 如何在 Ubuntu 下修复 apache 错误 "not within configured docroot"

问候专家和专家,我正在寻求有关apachephp配置问题的帮助。在我的etc/apache2/conf.d/virtual.conf文件中使用NameVirtualHost*行时,我已经在ubuntu服务器上通过apache2设置运行多个网站一段时间了,没有出现问题。我最近将服务器版本更新到最新的lts版本,现在无法运行php文件。我正在为位置“/home/www/[站点名称]/htdocs”运行我的所有站点,并且我已经在/etc/apache2/sites-available中设置并启用了我的所有站点。我还禁用了默认站点。我为每个站点文件指定了以下内容:#Indexes+Direct

php - Symfony Knp 菜单包 : set active a menu item even when its not on that menu

我创建了我的菜单生成器并且它有效。我的路线之一是/database但这有一个子路由:database/view/{id}我不想将View路由放入菜单项中,因为没有ID它就无法工作。但我希望当用户在View中时数据库路由处于事件状态。我该怎么做? 最佳答案 设法用这个小技巧解决了它:在添加所有子项之后但在返回我添加的菜单之前的menuBuider中$request=$this->container->get('request');$routeName=$request->get('_route');switch($routeName)

PHP 的 preg_match() 只返回匹配值

我正在做以下事情:$text='L\'utente_{nickname}tihainvitatoagiocare';$text_vars=preg_match('#\_{(.*?)\}#',$text,$matches);返回:Array([0]=>_{nickname}[1]=>nickname)如何才能只返回以下内容?Array([0]=>nickname) 最佳答案 来自preg_match()文档:Ifmatchesisprovided,thenitisfilledwiththeresultsofsearch.$matche

php - Cakephp 3 : Json render View not working

我一直在尝试在Cakephp3.0.11中设置Ajax调用。我在这里遵循了解释:http://book.cakephp.org/3.0/en/views/json-and-xml-views.html在路由中启用Json(但我不确定这是否有用):$routes->extensions(['json','xml','html']);我已经在Controller中设置了我的示例:$returnObject=newObjectReturn();$this->set('returnObject',$returnObject);$this->set('_serialize',['returnOb

php - 在 Laravel 5.1 中使用中间件时出现 Class jwt-auth does not exist 错误

我按照官方的JWT-Auth安装https://github.com/tymondesigns/jwt-auth/wiki/Installation.现在我的Controller中有一个中间件:$this->middleware('jwt-auth',['only'=>['postChange','postChoose']]);我还在config/app.php的提供程序数组中添加了Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class但是,当我向API发出请求时,我收到此错误消息:ReflectionExceptioninConta

PHP 反向 Preg_match

这个问题在这里已经有了答案:Regularexpressiontomatchalinethatdoesn'tcontainaword(33个答案)关闭4年前。if(preg_match("/".$filter."/i",$node)){echo$node;}这段代码过滤一个变量来决定是否显示它。$filter的一个示例条目是“office”或“164(.*)976”。想知道有没有简单的说法:如果$filter在$node中不匹配。以正则表达式的形式?所以...不是“if(!preg_match”,而是$filter=“!office”或“!164(.*)976”,但它有效吗?