草庐IT

property_types

全部标签

PHP property decleration 接受数组并且不接受可以在编译过程中评估的任何其他表达式

在研究PHP中的oop时,我注意到属性声明接受数组作为值,如此处所述PHPdocumentationclassTest{public$var7=array(true,false);}我注意到文档说:Thisdeclarationmayincludeaninitialization,butthisinitializationmustbeaconstantvalue--thatis,itmustbeabletobeevaluatedatcompiletimeandmustnotdependonrun-timeinformationinordertobeevaluated.阅读后this了解

php - 我可以使用 <input type ="button"/> 提交表单值吗?

我正在研究一个搜索引擎,我遇到了一个非常严重的问题GET和POST方法。我正在使用以避免每次按下按钮时页面都刷新。按下按钮后,我会显示一个结果(google_map、monumet图片、规范)。现在的问题是我想通过按此按钮提交并显示表单值+结果(google_map、monumet图片、规范)。这是一个问题,因为不提交表单值,我真的被卡住了。 最佳答案 当然,这是一个适合您的示例:index.phpWorkingExample$(document).ready(function(){$('#search-button').click

php - SOAP 错误 : Encoding: object has no 'FinalBookingDate' property

在开始之前,我知道,这个错误意味着我应该定义属性FinalBookingDate,但只要继续阅读,您就会理解我的观点。网址是:http://bestbuyhotel1.cangooroo.net/ws/2013/ClientBackOffice_b.asmx?op=getBookingList我首先使用SoapUi进行测试,并成功获得了我需要的列表:在php上,我只能得到这个响应:来自php的SoapClient是:$params=array('soap_version'=>SOAP_1_2,'compression'=>SOAP_COMPRESSION_ACCEPT|SOAP_COM

php - 如何实现这个: object->object->property

我看到很多代码都是这样调用的。一个例子:$person->head->eyes->color="brown";$person->head->size=10;$person->name="Daniel";如何实现上面写的内容? 最佳答案 这只是意味着$person、$person->head和$person->eyes每个都有其他对象的属性.head是$person的属性,eyes是$person->head的属性,等等.因此,例如,当您设置$person->head->size时,您正在设置$person->headsize属性,表

php - Yii2 无效调用 : Setting read-only property

我有一个Post模型,它与Tags有很多对多的关系。在Post模型中定义:publicfunctiongetTags(){return$this->hasMany(Tags::className(),['id'=>'tag_id'])->viaTable('post_tags',['post_id'=>'id']);}但是Post::tags是只读的。因此,当我尝试在Controller中设置它们时,出现错误:InvalidCall–yii\base\InvalidCallExceptionSettingread-onlyproperty:app\models\Post::tagsCo

php - 在 Symfony 中哪里为 PHP7 添加 'strict_types'?

我正在symfony中开始一个新项目,我已经从PHP56切换到PHP7。根据指南,您必须添加以下内容以反射(reflect)PHP7的新功能我应该在我的新symfony项目中的什么地方放置'strict_type'以避免在每个文件中都写'strict_type',以便在整个项目中全局反射(reflect)PHP7的新功能? 最佳答案 这是一个文件指令,所以你必须把它放在每个文件中。引用资料:http://php.net/manual/en/control-structures.declare.php

php - 在PHP的curl中指定multipart/form-data各部分的Content-Type

如何指定多部分/表单数据请求的特定部分的内容类型?图像的内容类型作为application/octet-stream发送,但服务器期望它是image/jpeg。这会导致服务器拒绝我的请求。$data["file"]="@/image.jpg";$data["title"]="Thetitle";$data["description"]="Thedescription";//makethePOSTrequest$curl=curl_init();curl_setopt($curl,CURLOPT_URL,$url);curl_setopt($curl,CURLOPT_VERBOSE,1)

php - 奏鸣曲管理员 - sonata_type_collection : select from the list of existing entities

我正在尝试使用PageHasImage桥接实体在Page和Image实体之间实现多对多关系。在PageAdmin中,我添加了如下字段:->add('galleryImages','sonata_type_collection',array('cascade_validation'=>false,'by_reference'=>false,'type_options'=>array('delete'=>false)),array('edit'=>'inline','inline'=>'table','sortable'=>'position','admin_code'=>'sonata.

php - Laravel Eloquent : belongsTo relationship - Error: Trying to get property of non-object

第一次尝试laraveleloquentrelatioinstip我知道这很简单,但我收到这个错误,不知道它出了什么问题我在数据库中有2个表,news和news_image在数据库中表格:newsid|header|detailsnews_imageid|image|news_id并且有2个模型News,newsImage新闻图像模型:classnewsImageextendsEloquant{protected$table='news_image';publicfunctionnews(){return$this->belongsTo('News');}}新闻模型classNewse

PHP7 : Methods with a scalar type declaration refuse to type juggle NULL values, 即使在弱/强制模式下

截至PHP7.0,标量类型提示int、float、string和bool可以包含在方法签名中。默认情况下,这些类型声明以弱/强制模式(或“typejuggling”模式)运行。根据PHPmanual:PHPwillcoercevaluesofthewrongtypeintotheexpectedscalartypeifpossible.Forexample,afunctionthatisgivenanintegerforaparameterthatexpectsastringwillgetavariableoftypestring.但即使可以将NULL强制转换为整数0,具有int类型提