草庐IT

filter_value

全部标签

php - 拉维Excel : how to get value of a cell?

我已经用LaravelExcel加载了.xls文件:Excel::load('public/files/20160621.xls',function($reader){//readacellvalue});如何读取加载的excel文件的单元格值?该部分的文档似乎不清楚。 最佳答案 publicfunctionget(){$excelFile...returnExcel::load($excelFile,function($doc){$sheet=$doc->getSheetByName('data');//sheetwithname

PHP 银条 ORM : Duplicate key value violates unique constraint for DataObject write

我的网站上有一个功能,可以非常快速地将一堆值保存到相同的DataObject类型。大多数时候没问题,但偶尔会出错ERROR:duplicatekeyvalueviolatesuniqueconstraint...通读我看到的文档:SilverStripedoesnotusethedatabase'sbuilt-inauto-numberingsystem.Instead,itwillgenerateanewIDbyadding1tothecurrentmaximumID之前查看代码,它看起来像是从主键中检索最大数量,插入具有该ID的记录,然后设置DataObject的值并再次写入。在我

php - 如何使用插件、add_filter 删除或更改 wordpress 中的 <title> 标签?

我需要更改或删除使用插件在wordpress中标记例如Myoldtitle=>Newtitle我试试functionplugin_title($content){$content=str_replace('Myoldtitle','Newtitle',$content);return$content;}add_filter('wp_head','plugin_title');//但它不起作用。任何的想法? 最佳答案 尝试使用wp_title钩子(Hook)add_filter('wp_title','custom_title',20

php - 可变产品选择器 : Getting the live selected values

在WooCommerce中,使用以下代码在简单和可变产品的产品价格后添加自定义标签:add_filter('woocommerce_variation_price_html','prices_custom_labels',10,2);add_filter('woocommerce_price_html','prices_custom_labels',10,2);functionprices_custom_labels($price,$product){//SetHEREyourcustomlabelsnames$per_dozen=''.__('perdozen','woocommer

php - Apache + PHP : how to change the value of $_SERVER ['SERVER_NAME' ] in apache?

例如,我有mysite.com和beta.mysite.com。两者都使用virtualHost指令指向同一个索引文件。我将在apacheconf中做什么,以便当我访问$_SERVER['SERVER_NAME']时,该值仍然是mysite.com?这应该是灵活的,只有beta会被删除。 最佳答案 也许您可以在VirtualHost指令中使用ServerAlias,并且只使用一个VirtualHost指令:ServerNamemysite.comServerAliasbeta.mysite.com...

php - $this->"variable value"OOP PHP

我想知道这是否可能,如果可能,我应该如何实现:$this->id$this->(并在这里更改值)例如:我可能有$this->id$this->allID$this->proj_id我怎样才能使我实际上拥有$this->(此处为$myvariable,其中有一个唯一的名称)? 最佳答案 你可以简单地使用这个:$variable='id';if(isset($this->{$variable})){echo$this->{$variable};} 关于php-$this->"variable

PHP 变量 "default value"

我想从session中获取一个值,但如果未定义则使用默认值。当然,我想绕过PHP通知。你可以写一个函数来做这个functionget(&$var,$default){if(isset($var))return$var;return$default;}echoget($foo,"bar\n");$foobar="foobar";echoget($foobar,"ERROR");Exampleinaction有没有办法不用在每个文件中定义这个函数就可以做到这一点? 最佳答案 您可以在一个脚本中定义它,然后在您的其他脚本中require_

php - FILTER_VALIDATE 与 Preg_match。使用哪一个?

要验证输入日期,无论是表单URL还是来自表单,您通常使用哪种技术?我一直在看PHPFilters但我很少在任何代码中看到它们。我平时看到过preg_mach的用法,例如:$numbers="/^[0-9]+$/D";if(preg_match($numbers,$var)){echo"isnumber";}代替:if(!filter_var($var,FILTER_VALIDATE_INT))echo"isnumber";}使用一个或另一个有什么好处吗?谢谢! 最佳答案 我的两分钱:视情况而定。这取决于您是否应该在正则表达式上使用过

php - Curl 返回 true 而不是 value

我正在尝试制作一个简单的API。但是,不知道为什么,但我得到的是true而不是应该返回的值。这是curl代码。try{$target_url="myurl";$post=array('auth_token'=>'123456'//postyourauthtokenhere//'file_contents'=>'@'.$_FILES['file']['temp_name']);//thenameoftheinputtypeisfile,youcanchangeitinyourHTML.);$ch=curl_init();if($ch==false){echo"Couldntinitial

php - 您可以使用带有 PHP filter_var() 和 filter_input() 的自定义过滤器吗

PHPFilters非常酷,但是如果过滤器与您想要的不完全匹配怎么办?您可以创建自定义过滤器吗? 最佳答案 是的,您可以使用FILTER_CALLBACK并提供您自己的过滤器函数(作为回调)。 关于php-您可以使用带有PHPfilter_var()和filter_input()的自定义过滤器吗,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/3016861/