草庐IT

parameter_name

全部标签

php - 警告 : get_class() expects parameter 1 to be object

一周前我写了一个代码,它运行良好。但是今天当我检查它时,它给了我一些问题,比如Warning:get_class()expectsparameter1tobeobject,arraygivenin/home/ccc/public_html/horoscope/xml2json.phponline182Warning:get_class()expectsparameter1tobeobject,stringgivenin/home/ccc/public_html/horoscope/xml2json.phponline182Warning:get_class()expectsparame

php - Wordpress 警告 : call_user_func_array() expects parameter 1 to be a valid callback, 数组必须恰好有两个成员

我正在尝试添加一个自定义函数,该函数将添加Access-Control-Allow-Originheader,因为我无法访问服务器上的.conf文件。下面是我的代码;add_filter('wp_headers',array('eg_send_cors_headers'),10,1);functioneg_send_cors_headers($headers){$headers['Access-Control-Allow-Origin']=get_http_origin();$headers['Access-Control-Allow-Credentials']='true';if('

php - Symfony2 如何在 Controller 中使用 parameters.yml 作为变量

我正在处理一个Symfony2项目。我正在尝试使用在parameters.yml中清除的一组数据,并在我的一个Controller中使用这些数据。我已阅读this在有关getParameters()的Symfony2文档中,但它不起作用。在我的parameters.yml中我这样做了:sitemap_root_url:http:/example.co.uk/news/在我的Controller中,我正在尝试这样做:$this->test=$this->container->getParameters('sitemap_root_url');这是我得到的错误:Notice:Undefin

php - Laravel 5.1 auth attempt with extra parameters using default auth controller and middleware

如何使用默认身份验证Controller和中间件使用额外参数覆盖Laravel5.1身份验证尝试?假设我有一个状态为=active或inactive的额外字段。我该如何编写该尝试方法? 最佳答案 如documentation中所述您可以传递一个变量数组,它们的键是您要在数据库中验证值的列。$request->get('email'),'password'=>$request->get('password'),'active'=>$request->get('active')]);if($attempt){returnredirect

php - 给出的错误 : array_flip() expects parameter 1 to be array, 字符串

我是Laravel的新手,遇到以下错误,array_flip()expectsparameter1tobearray,stringgiveninGuardsAttributes.phpline188atHandleExceptions->handleError(2,'array_flip()expectsparameter1tobearray,stringgiven','/Users/aaronmk2/Desktop/CodingDojo/php/onetoone/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Con

PHP 7.2.7 : Attempted to call an undefined method named "setEncryptionName" of class "ZipArchive"

我正在尝试使用PHP7.2.7创建一个加密的、受密码保护的ZIP文件。但是,我收到以下错误消息:Attemptedtocallanundefinedmethodnamed"setEncryptionName"ofclass"ZipArchive".http://php.net/manual/en/ziparchive.setencryptionname.php如果我删除$zip->setEncryptionName()那么一切都会100%,除了ZIP文件没有密码保护。我在Google和论坛上进行了搜索,但找不到遇到过类似问题的人,可能是因为PHP版本和功能仍然太新。

php - 如何从 PDO 故障 "Error!: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined"中获取更多信息?

每隔一段时间我就会收到一个错误,例如以下PDO错误:Error!:SQLSTATE[HY093]:Invalidparameternumber:parameterwasnotdefined有没有办法得到更具体的错误,例如行号、文件名、丢失的参数等,而不是模糊的消息? 最佳答案 首先,确保您已将PDO设置为在出错时抛出异常:$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);现在,确保每个PDO操作/操作集都包含在try/catchblock中,如下所示:try{$

php array_filter function not found or invalid function name 不管我输入什么

我之前从未使用过array_filter函数,所以无论我使用什么作为函数名称,它都会给我错误,请尝试一下Warning:array_filter()expectsparameter2tobeavalidcallback,function'odd'notfoundorinvalidfunctionnamein我什至采取了直接从php手册页复制粘贴示例的步骤,它给了我同样的错误。代码:functionodd($var){//returnswhethertheinputintegerisoddreturn($var&1);}functioncalculate($res,$period,$el

PHP 文件上传 : keep both files if same name

在PHP中是否有任何漂亮的解决方案允许我在文件名已经存在的情况下使用自动递增数字扩展文件名?我不想在一些不可读的东西中重命名上传的文件。所以我认为这样会很好:(允许所有图像文件。)Cover.pngCover(1).pngCover(2).png… 最佳答案 首先,让我们分开扩展名和文件名:$file=pathinfo();为了便于文件检查和追加,将文件名保存到新变量中:$filename=$file['filename'];然后,让我们检查文件是否已经存在并保存新的文件名,直到它不存在为止:$i=1;while(file_exis

php - 编译失败 : unknown property name after\P or\p

您好,我想匹配一个字符串:“\parhello\parworld”针对我的正则表达式模式->\\par但是,我得到一个Compilationfailed:unknownpropertynameafter\Por\p我相信我的正则表达式规则被视为unicode字符属性。我如何转义它并按原样运行模式?我像这样将它包含在PDO函数中。functionsqlite_regExp($sql,$db){if($db->sqliteCreateFunction("regexp","preg_match",2)===FALSE)exit("Failedcreatingfunction!");if($r