草庐IT

PR_SET_NAME

全部标签

php - 面向对象设计 : Return Values or Set Property?

在这种情况下,什么将被视为“最佳实践”。我有一个正在收集远程资源的类,它看起来有点像这样:classGather{publicfunctiongetAll($locations){$results=array('All','My','Results');return$results;}}我的问题是,返回结果或将它们分配为属性是否被视为最佳做法?即。//This$results=$gatherer->getAll();//vsThis$gatherer->getAll();//now$gatherer->resultscanbeused这很可能是我想多了,但我没有接受过正规培训,我想知道

php - 为什么不鼓励使用 global $object_name?

我有两个类,目前我使用这个从另一个引用一个类:ClassB::func(){global$classAObject;echo$classAObject->whatever();}但是,有人告诉我不鼓励使用global。是吗,为什么? 最佳答案 不使用全局变量的原因有很多。这里只是一些:范围在大型系统中,如果您重复使用半通用名称,很容易意外地重新分配全局变量全局范围内的变量会增加脚本的内存占用。不总是很重要,但可以在其他一些语言中,不需要获取全局变量——默认情况下它们是可用的——如果你忘记将同名变量声明为本地变量,这可能会导致错误联轴

php - ini_set/ini_get memory_limit 恢复内存 php

我正在编写一个脚本,我需要在某个时候将内存限制设置为非常高的值。但是,之后我需要恢复内存限制。但是,如果您的脚本没有调用ini_set来设置内存限制,则ini_get会返回-1。我正在尝试做这样的事情:$oldLimit=ini_get("memory_limit");ini_set("memory_limit","220M");dosomething//restorememoryini_set("memory_limit",-1);但是,$oldLimit是-1。-1在这种情况下意味着什么。提前致谢。 最佳答案 -1表示无限制,换

php - 如何使 geoip_country_name_by_name() 工作?

我想收集登录我网站的用户的国家/地区名称。所以我用了geoip_country_name_by_name()用于此目的的php函数。但是我遇到了一个fatalerror:Fatalerror:Calltoundefinedfunctiongeoip_country_name_by_name()我怎样才能避免这个错误?有没有其他方法可以使用php获取国家名称?有人可以帮帮我吗? 最佳答案 听起来您的计算机上没有安装扩展程序。查看此链接,它是一个PECL扩展。http://www.php.net/manual/en/geoip.setu

PHP YouTube API - thumbnails.set 失败

我正在尝试使用YouTubeAPI和google-api-php-client库更新YouTube上的视频缩略图。我们的版本是1.0.3-beta。我已经复制/粘贴了example,并将我们的client_id和client_secret更改为我知道有效的值,因为我仍然可以使用这些值上传视频现在,我无法设置缩略图(在我刚刚使用相同凭据上传的视频上)。这是我得到的错误:Anclienterroroccurred:ErrorcallingPUThttps://www.googleapis.com/upload/youtube/v3/thumbnails/set?videoId=wL3Rt0

php - code igniter 模块化扩展 - 对 MX_Router::_set_default_controller() 的访问级别必须是公共(public)的(如在 CI_Router 类中)

我从中安装了流行的模块化扩展-HMVChttps://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc并使用codeigniter2.2.2进行设置但是当一切正常时,我收到此错误AccessleveltoMX_Router::_set_default_controller()mustbepublic(asinclassCI_Router)inC:..\application\third_party\MX\Router.phponline241 最佳答案 方案一

php - ERR_ICANN_NAME_COLLISION 在主机文件中使用 url 而不是 ip

我正在尝试使用laravelhomestead并将“homestead.dev”重定向到“192.168.10.10”。我可以看到使用IP的网站,但看不到“homestead.dev”。我收到这个错误:ERR_ICANN_NAME_COLLISIONPinghomestead.dev响应为127.0.53.53。我也可以用这个访问网站:http://127.0.53.53:8000/.我的宅基地.yaml:ip:"192.168.10.10"memory:2048cpus:1provider:virtualboxauthorize:~/.ssh/id_rsa.pubkeys:-~/.s

php - WooCommerce 法典 : how to set the user/customer on an order

我正在编写一个负责付款和交付的WooCommerce插件。现在我正在根据当前购物车创建订单。一切正常,元素和费用正确,唯一的问题是订单显示为“访客”,而不是当前登录的用户(即使正确的电子邮件地址该用户在订单上)。这是我的代码:$cart=WC()->cart;$checkout=WC()->checkout();$order_id=$checkout->create_order();$order=wc_get_order($order_id);$order->user_id=apply_filters('woocommerce_checkout_customer_id',get_cur

php - Laravel 5.4 类 'App\Providers\AppServiceProvider' 在我设置应用程序 :name 后未找到

我需要你的帮助解决新手问题。在我的本地项目中,我使用命令phpartisanapp:namexyz然后我将其投入生产,但出现错误:production.ERROR:Symfony\Component\Debug\Exception\FatalThrowableError:Class'App\Providers\AppServiceProvider'notfoundin/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:612我该如何解决? 最佳

php - 如何使 __set 也适用于 PHP 中的静态操作?

当我调用self::$parameter=1;时,__set没有被调用。有解决办法吗? 最佳答案 来自manual:Propertyoverloadingonlyworksinobjectcontext.Thesemagicmethodswillnotbetriggeredinstaticcontext.Thereforethesemethodsshouldnotbedeclaredstatic.AsofPHP5.3.0,awarningisissuedifoneofthemagicoverloadingmethodsisdecla