草庐IT

Match_parent

全部标签

php - 是否将大量参数传递给 parent::__construct 代码异味/糟糕的 OOP?

我正在写一些代码,我开始对凌乱的parent::__construct调用感到有点不舒服,我想知道首先它是不是糟糕的OOP实践,其次是否有更简洁的方法来做到这一点?请参阅下面触发我问题的特别极端的示例。setBrowseNodeId($BrowseNodeId);}protectedfunctionsetBrowseNodeId($BrowseNodeId){if(is_string($BrowseNodeId)){$this->BrowseNodeId=$BrowseNodeId;}else{thrownewException('BrowseNodeLookupRequestPara

php - Laravel Blade : Getting access to a variable in a nested partial from a parent view

我的父View是这样的:show.blade.php@include('inquiries.partials.inquiries')它使用以下部分:查询.blade.php@foreach($inquiryas$key=>$item)@include('inquiries.partials.inquiry')@endforeach其中使用了另一个部分:查询.blade.php...@yield('inquiry.toolbar','')在show.blade.php中,我想为inquiry.blade.php定义inquiry.toolbar部分,但是我需要访问inquiries.bl

php - Laravel 5.2 登录总是抛出 "These credentials do not match our records."

我正在尝试使用Laravel5.2实现身份验证。我已经处理这个问题好几个小时了,但我总是收到“这些凭证与我们的记录不符”的提示。尝试登录时。我试过弄乱路由、调整用户表中的密码列大小、尝试自定义登录验证器等。就是无法让它工作。这就是我通过迁移创建用户表的方式:注意事项:我必须在学校项目中使用原始语句。Laravel建议密码字段需要60个字符(已经尝试过100个)Laravel需要100个字符的remember_token列编辑:数据库和用户表已成功创建,用户数据已在注册时保存。代码:DB::statement("CREATETABLEusers(idINTPRIMARYKEYAUTO_I

php - parent::method() - 调用非静态方法

我不明白在PHP中调用父方法的概念。父方法不是静态的,但它是静态调用的-通常PHP会抛出错误/警告。问题是,这是PHP的怪癖,还是在OOP中应该如此?以php.net为例:\n";}}classBextendsA{functionexample(){echo"IamB::example()andprovideadditionalfunctionality.\n";parent::example();}}$b=newB;//ThiswillcallB::example(),whichwillinturncallA::example().$b->example();?>http://php

php preg_match -> 在变量中保存匹配值?

我的$content变量存储了一个youtube视频链接。$youtubeurl="/(\[TRACK=)((http|https)(\:\/\/)(www|it|co\.uk|ie|br|pl|jp|fr|es|nl|de)(\.youtube\.)(com|it|co\.uk|ie|br|pl|jp|fr|es|nl|de)([a-zA-Z0-9\-\.\/\?_=&;]*))(\])/si";$video=preg_match($youtubeurl,$content,$found);print_r($video);//1如何将匹配字符串的值存储在变量中?现在如果我print_r

PHP preg_match 除单词外的任何字符

这个问题在这里已经有了答案:Regularexpressiontomatchalinethatdoesn'tcontainaword(33个答案)RegularExpressionblocknegation(1个回答)关闭9年前。要匹配除指定字符(在此示例中为“f”)之外的任何字符,我使用[^f]+。但是如何匹配指定单词以外的任意字符呢?像[^word]+这样的东西示例:haystack:"bla1bla2bla3bla4hellobla5bla6bla7"(haystack包含HTML和换行符)针:"bla1bla2bla3bla4"所以我想捕捉从开始到"hello"的所有内容

php - Symfony2 "Parameter ""for route ""must match "[^/]++"(""given) to generate a corresponding URL."

我有这个路线文件:indexRechercheZones:path:/gestionzonestechniquesdefaults:{_controller:MySpaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:indexZonesTechnique}requirements:methods: GETmodifierZones:path:/gestionzonestechniques/modifier/{nom}defaults:{_controller:MySpaceGestionEquipementsTec

php - 这是 php 中的快速进程 strpos()/stripos() 或 preg_match()

我只想知道在php中,strpos()/stripos()或preg_match()函数中哪一个会更快。 最佳答案 我找到了thisblog已经对你的问题做了一些测试,结果是:strpos()比preg_match()快3-16倍stripos()比strpos()慢2-30倍stripos()比preg_match()快20-100%无大小写修饰符“//i”在preg_match()中使用正则表达式并不比使用正则表达式快长字符串在preg_match()中使用utf8修饰符“//u”使其慢2倍使用的代码是:

php - Symfony2.1映射错误: class_parents()

我在Symfony2.1项目中尝试使用Doctrine2从表(通过实体)获取数据时遇到问题。这是我收到错误的Controller:/***Countrylist*/publicfunctioncountrylistAction(){$em=$this->getDoctrine()->getManager();$countryList=$em->getRepository('ProjectBaseBundle:SYS_TCountry')->findAll();$serializer=newSerializer(array(newGetSetMethodNormalizer()),arr

php - 尝试在 Preg_Match 中查找正斜杠

我已经搜索了几个小时,试图找到解决这个问题的方法。我正在尝试确定REQUESTURI是否合法并从那里分解它。$samplerequesturi="/variable/12345678910";判断是否合法,第一段variable只有字母,长度可变。第二部分是数字,总共应该有11个。我的问题是转义正斜杠,以便它在uri中匹配。我试过:preg_match("/^[\/]{1}[a-z][\/]{1}[0-9]{11}+$/",$samplerequesturi)preg_match("/^[\\/]{1}[a-z][\\/]{1}[0-9]{11}+$/",$samplerequestu