草庐IT

fnon-call-exceptions

全部标签

php - 如何解决 Call to a member function notify() on array? (拉拉维尔 5.3)

我的听众是这样的:data->notify(New\App\Notifications\CheckoutOrder($event->data));}}如果我运行dd($event),结果是这样的:执行时出现错误:Calltoamemberfunctionnotify()onarray如何解决? 最佳答案 您需要使用notify()在具有Illuminate\Notifications\Notifiable特征的模型上,但绝对不在数组上。例如,你可以先获取一个User的实例:$user=User::where('email',$eve

php - PHP : The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect 中的 FreeTDS 错误

我必须使用ODBC从ArchLinux连接到MSSQL服务器。我使用FreeTDS,并使用isql,它可以正常工作:isqlsqlexpressdev开发但不是在PHP中。我在交互模式下使用PHP:PHP>$conn=odbc_connect("sqlexpress",'dev','Dev');PHP>$a=odbc_exec($conn,'SELECT*FROMmeasures;');PHPWarning:odbc_exec():SQLerror:[FreeTDS][SQLServer]Theincomingtabulardatastream(TDS)remoteprocedurec

php - "Wrong parameters for Exception"创建Exception子类时

这是我的代码classMyExceptionextendsException{publicfunction__construct($message,$code=0,Exception$previous=null){parent::__construct($message,$code,$previous);}publicfunction__toString(){return__CLASS__.":[{$this->code}]:{$this->message}\n";}}这里是错误Fatalerror:WrongparametersforException([string$excepti

php - 使用 __call() 而不是 getter 和 setter 是否正确?

关于良好实践的主题,对需要getter和setter的类使用__call()是否正确?参见DoctrineEntity的示例:https://gist.github.com/devmatheus/10668172#file-sessao1-php我知道性能会受到影响,但这会减少编程时间,您怎么看? 最佳答案 如您所说,性能会降低,但更好的设计总是胜过性能。具有更多Ram和CPU的服务器并不像开发人员那样昂贵。如果您需要动态调用的方法,我认为这是一个很好的观点。,但是,它应该通过PHPDoc进行详细记录(它有助于IDE完成代码,开发人

PHP/SQLite3 : Fatal error: Call to undefined function sqlite_num_rows()

当我调用函数sqlite_num_rows时出现此错误。它一定不是依赖性问题,因为其他Sqlite函数正在运行。我能够打开连接并从数据库获取数据。 最佳答案 晚了4年,但我遇到了同样的问题,所以这是我为遇到同样问题的任何人提供的解决方案//$dbisthedatabasehandle$result=$db->query("SELECT*FROMtable_name");$rows=0;//setrowcounterto0while($row=$result->fetchArray()){$rows+=1;//+1tothecount

php - Laravel 5.2 curl_init() 抛出错误 "Call to undefined function"

我正在尝试使用curl在laravel中使用FCM,但出现错误。首先,我在我的一个Controller中编写了一个php代码:$first_name=$request->input('first_name');//FCMapiURL$url='https://fcm.googleapis.com/fcm/send';//api_keyavailableinFirebaseConsole->ProjectSettings->CLOUDMESSAGING->Serverkey$server_key='AIzaSyA1RyuAGGPASh_flFCwiyd9ZHEMYlhQOho';$tar

php - Laravel "Call to undefined method"仅在生产中发生

我有2个Controller函数,它们调用位于应用程序文件夹下的类的静态函数。Controller\UserResController.phppublicfunctionshow($id,Request$request){return\App\User::show($id,$request);}Conrtollers\Other\UserResController.phppublicfunctionshow($id,Request$request){//othercodesreturn\App\User::show($id,$request);}应用\用户.phppublicstati

php - 什么时候应该记录异常(exception)情况?

假设以下片段:publicfunctionfoo(){return$this->dependency->bar();}如果已知dependency::bar()会抛出异常,但foo()预计不会处理它。foo()的文档block中是否应该有一个@throws条目?或者这应该是隐含的?phpdoc文档对此有些含糊。假设dependency是基于接口(interface)注入(inject)的;接口(interface)文档是否应该说明该方法可以抛出指定的异常。异常应该由调用代码处理还是无关紧要?一路语义:) 最佳答案 您已经创建了公共(

PHP fatal error : Uncaught exception 'Exception' with message

我有一个PHP脚本连接到一个api并将信息发布到他们的系统,但是当它尝试连接时它抛出一个fatalerror:Fatalerror:Uncaughtexception'Exception'withmessage'Problemwith'http://apitestserver.co.uk:9000/Service.svc/Items'in/var/www/html/e/connect_test.php:17Stacktrace:#0/var/www/html/e/connect_test.php(39):do_http_request('http://apitest....','hel

php - 什么场景需要在php中使用call_user_func()

这个问题在这里已经有了答案:PHPcall_user_funcvs.justcallingfunction(8个答案)关闭4个月前。我不理解函数call_user_func(),因为我知道它是如何工作的,但我不确定为什么需要它或在什么情况下在php中使用它。就我而言,为什么不直接调用函数而不是用函数调用函数呢?谢谢!