草庐IT

function_type

全部标签

PHP 7 - 不支持声明 'strict_types'

我在一个小项目中使用PHP7,也在我的本地和生产服务器中使用相同的配置。一切都在我的本地服务器上工作,但在为LAMP设置后在生产服务器上,我无法在/etc/php/7.0/apache下找到apache文件夹,所以我遇到了内部服务器错误,所以我在apache中添加了.confPHPINIDir/path/to/new/php_ini然后内部服务器错误消失了,现在我得到了这个:Warning:Unsupporteddeclare'strict_types'in/var/www/html/index.phponline2知道为什么!!提前致谢 最佳答案

php - Sage One API - unsupported_grant_type

我正在尝试按照docs获取SageOneAPI的访问token使用Guzzle(v6)/Laravel5.2(Laravel的参与与本题无关),卡在“请求访问token”阶段。错误Clienterror:`POSThttps://api.sageone.com/oauth2/token`resultedina`400BadRequest`response:{"error":"unsupported_grant_type"}违规代码$client=newClient(['base_uri'=>'https://api.sageone.com','headers'=>['content_t

php - 拉维尔 5.2 : Creating a custom route function - extending route

基本上,我想创建自己的Route::custom函数。这是因为我一直在为整个站点的多个路由使用相同的组和中间件(我还使用带有子域的模块,所以我们正在谈论为每个路由节省5-6行代码)我只想让Route::custom调用两个或三个其他Route函数。例如:Route::Module('forum')替换为Route::group(['middleware'=>['web','auth'],'domain'=>'forum.'.env('SITE_DOMAIN','example.com')],function(){Route::group(['middleware'=>'permissi

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 7 | chr() + strict_types === 错误?

我尝试将我的工作PHP5.x代码转换为更现代的PHP7.x代码库,因此我添加了“declare(strict_types=1);”在第一步中,但它没有按预期工作。代码:ord(chr(ord("\xE9")/64)|"\xC0");演示:https://3v4l.org/680tsgithub:https://github.com/voku/portable-utf8/blob/master/src/voku/helper/UTF8.php#L6613PHP7.0(没有strict_types=1)===195PHP>7.0(strict_types=1)===192也许有人可以给我解

php - 为什么我们需要 function_exists?

为什么我们需要检查用户定义函数的function_exists?内部或核心PHP函数看起来没问题,但如果用户知道并自己定义了一个函数,那么为什么还需要检查它是否存在?下面是自定义的用户定义函数if(!function_exists('bia_register_menu')){functionbia_register_menu(){register_nav_menu('primary-menu',__('PrimaryMenu'));}add_action('init','bia_register_menu');}谢谢 最佳答案 确保

php - MIME在PHP Mail Function Header中的作用是什么

有人能告诉我MIME-Version:1.0在phphtmlmail()函数中的作用是什么,为什么我们要使用它?我已经搜索过了,但找不到一个清晰的解释?//Alwayssetcontent-typewhensendingHTMLemail$headers="MIME-Version:1.0"."\r\n";$headers.="Content-type:text/html;charset=UTF-8"."\r\n";谢谢 最佳答案 mime版本在理论上允许对mime引入更新,但在实践中它没有被使用,并且总是设置为1.0。因为根据mi

PHPUnit RabbitMQ : write test for create connection function

我面临以下问题。我写了一个函数,它在给定所需参数的情况下创建一个连接对象(AMQPConnection)。现在想写相应的单元测试。如果没有运行RabbitMQ代理,我只是不知道该怎么做。这是有问题的功能:publicfunctiongetConnection($hostKey,array$params){$connection=null;try{$connection=newAMQPConnection($params['host'],$params['port'],$params['username'],$params['password'],$params['vhost']);//

php - Symfony2 Can't inherit abstract function Validator\ValidatorInterface::validate() (之前在\Validator\ValidatorInterface中声明了抽象)

如果我使用带有--write参数的symfony控制台命令generate:doctrine:crud我会得到一个自动生成的Controller,它只在indexAction路由,但不在其他路由中(newAction、deleteAction、updateAction)。我认为问题在于表单创建。产生的错误如下:CompileError:Can'tinheritabstractfunctionSymfony\Component\Validator\ValidatorInterface::validate()(previouslydeclaredabstractinSymfony\Comp

php - Symfony/Doctrine : getJoinTableName() must be of the type array, 给定为空

我有这2个类,它们之间有ManyToMany关联:Nursery.phpnamespaceVS\CrmBundle\Entity;useDoctrine\Common\Collections\ArrayCollection;useDoctrine\ORM\MappingasORM;/***Nursery**@ORM\Table(name="Nursery")*@ORM\Entity(repositoryClass="VS\CrmBundle\Repository\NurseryRepository")*/classNursery{/***@varint**@ORM\Column(nam