草庐IT

null-stream

全部标签

php - 如果 php 自动为您完成,是否需要将类内的属性初始化为 null?

对来自两个类中的任何一个的对象执行var_dump会得到相同的结果ClassNode{public$parent=null;public$right=null;public$left=null;function__construct($data){$this->data=$data;}}ClassNode{public$parent;public$right;public$left;function__construct($data){$this->data=$data;}}例如$a=newNode(2);var_dump($a);为上述任一类返回以下内容object(Node)#1(

php - 应用程序/控制台 Assets :install to S3 using stream wrapper errors

我有一个流包装器配置为使用Gaufrette与amazons3一起工作bundle来管理文件系统。我可以使用assetic成功转储Assets,我当前的配置如下:knp_gaufrette:adapters:amazon:amazon_s3:amazon_s3_id:site_store.s3bucket_name:%site_store.bucket_name%create:truefilesystems:amazon:adapter:amazonstream_wrapper:protocol:s3filesystems:-amazonassetic:read_from:%cdn_p

php - Null 有课吗?

涉及Symfony1.4和Propel,但我不确定它们会导致下面描述的奇怪行为。$this->_parent=TestPeer::retrieveByPK($this->getParentId());var_dump(get_class($this->_parent),$this->_parent);打印出'Test'和'null'。怎么会这样?附言1/$this->getParentId()返回整数,DB中没有对应的记录,所以$this->_parent应该为null。2/php5.5.6,xdebug,opcache 最佳答案

php - 使用 !is_null() 的正确方法

如果我正确理解is_null,PHP面向对象解决方案中的一个示例似乎有缺陷。书中示例代码如下:if(!is_null($required)&&!is_array($required)){thrownewException('Thenamesofrequiredfieldsmustbeanarray,evenifonlyonefieldisrequired.');}这段代码应该测试var$required不是NULL而是一个数组。据我了解,如果变量未设置或为NULL,is_null()将返回TRUE。那么,如果您试图在变量未设置、NULL或不是数组时抛出异常,那么在该示例中否定is_nu

php - Laravel 查询生成器 - 将列设置为 NULL

我正在尝试将我的列更新为NULL,但该值作为字符串传递,并将该列设置为0而不是null。$update=DB::table('users')->where('id',$primary_key)->update(array($column_name=>$new_value));如何确保该列更改为NULL? 最佳答案 尝试以下操作:$update=DB::table('users')->where('id',$primary_key)->update(array($column_name=>Input::has('FormFieldNa

php - 获取 "Integrity constraint violation: 1048 Column ' payment_id' cannot be null"using Doctrine & Symfony

我已经被困了几天来处理这个问题。我一直在查看其他StackOverflow问题和不同的论坛,但我无法让它工作,所以这就是这个问题的原因。我正在开发一个包含付款的系统,所以我创建了一个“付款”类,如下所示:/***Payment**@ORM\Table()*@ORM\Entity(repositoryClass="PaymentRepository")*/classPayment{/***@varinteger**@ORM\Column(name="id",type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AUTO")*@JMS\

PHPUnit 错误 "Failed to open stream: No such file or directory"

我刚刚安装了PHPUnitTesting,但出于某种原因它无法读取我的文件。我确信它在正确的路径中,但为什么PHPUnit找不到它?这是我的示例代码:函数.php这是要测试的代码和文件:函数测试.phpassertEquals(2,$result);}}?>我该怎么做才能让它发挥作用并通过测试? 最佳答案 您应该能够使用__DIR__。"/data/functions.php"在你的include语句中(这是前后两个下划线)。我在我的测试环境中做了一个快速测试,没有任何问题。__DIR__魔术常量为您提供了您正在运行的测试文件的完整

javascript - php中javascript按钮上的innerHTML null

我有一个在PHP函数中调用javascript函数的按钮:这是Chrome控制台打印innerHTML空错误的代码行:echo'  '.$commentVotes.'  ';注意:$rownNr由php代码成功检索,控制台打印它,所以我确定以下JS函数正确获取它:functionupvoteComment(commentID,rowNr){varrowNr=rowNr;$.ajax({url:"vote-comment.php?isUpvoted=true&commentID="+commentID,type:"GET",success:func

PHP 警告 : Unknown: failed to open stream: Permission denied in Unknown on line 0

我从Windows10上的PHP、wampserver和Composer开始,这将是一个星期我无法解决这个问题:当我键入时:php-Slocalhost:8000-ddisplay_errors=1public/在浏览器上运行:“localhost:8000/test”,我有这个错误:Warning:Unknown:failedtoopenstream:PermissiondeniedinUnknownonline0Fatalerror:Unknown:Failedopeningrequired'public/'(include_path='.;C:\wamp64\bin\php7.1

php - 在带有准备好的语句的 INSERT 或 UPDATE 中使用 NULL 值

有时我需要在表中插入一些空值,或更新它们并将值设置为NULL。我在Postgres文档的某处读到这无法完成,但可以使用默认值欺骗:pg_query("INSERTINTOmy_table(col_a,col_b)VALUES('whatever',default)我知道在这个例子中我会得到相同的结果:pg_query("INSERTINTOmy_table(col_a)VALUES('whatever')但是问题来自准备好的语句:pg_prepare($pgconn,'insert_null_val',"INSERTINTOmy_table(col_a,col_b)VALUES($1,