草庐IT

Wzero-as-null-pointer-constant

全部标签

php - 为什么下面的代码打印出 10 而不是 null?

以下代码输出10。这是为什么?c=10;}}classbextendsa{publicfunctionprint_a(){print$this->c;}}$b=newb;$b->print_a(); 最佳答案 因为publicfunctiona()是一个构造函数。Forbackwardscompatibility,ifPHP5cannotfinda__construct()functionforagivenclass,andtheclassdidnotinheritonefromaparentclass,itwillsearchfo

php - 使用 empty() 函数检查对象是否为 null 是否正确?

说,$obj=$this->someFunc();//thisreturnsanobjectif(empty($obj)){//suppose$objisnull,itdoesworkscorrectly}在http://php.net/manual/en/function.empty.php,empty()仅用于变量和数组。但是,这是正确的方法吗? 最佳答案 php有函数is_null()来判断一个对象是否为空:http://php.net/manual/en/function.is-null.php

php - 在 NetBeans 中对 false、true、null 使用小写常量

有什么方法可以将它们设置为小写的自动完成代码?它们自动以大写形式出现,我知道常量是以大写形式定义的,但我更喜欢它们的小写形式。 最佳答案 我在C:\ProgramFiles\NetBeans6.9.1\php\phpstubs\phpruntime\Core.php中找到了下一个define('LOG_PERROR',32);define('TRUE',true);define('FALSE',false);define('NULL',null);define('ZEND_THREAD_SAFE',false);define('ZE

php - 为什么我的 PHP 数组给我 "Cannot use object of type stdClass as array"?

任何人都可以在这里提供帮助,我正在使用一个数组来拆分一些数据,并且在附加到的View上我收到了上面的错误。这是我的代码:用于ajaxView的PHP:$images=array();$data_link=array();$data_id=array();$data_likes=array();$data_text=array();foreach($mediaas$data){//dd($data->caption);$images[]=array(//dd($data->caption),"data_url"=>$data->images->standard_resolution->u

php - 为什么当我手动为 $_POST 数组赋值时 filter_input() 返回 NULL?

我正在做一些关于数据验证的练习,并决定弄乱filter_input()函数。当我尝试运行这段代码时:$_POST['var']=10;$filtered=filter_input(INPUT_POST,'var',FILTER_VALIDATE_FLOAT);var_dump($filtered);var_dump($filtered)返回NULL。我知道如果通过提交表单为$_POST['var']分配了一个值,代码就可以工作,但我只是想知道为什么手动为$_POST[]数组不返回float(10)? 最佳答案 filter_inpu

php - 函数内的全局变量值为 NULL

在我的代码中,我有一个初始化MySQLi类的文件。归档一个:$db=newDatabase();//MySQLiclass无论如何,有一个包含这个数据库类的文件。该文件还包括其他在其中声明了函数的文件。我正在使用global联系$db文件b:functionxy(){global$db;$sql="..."return$db->getArray($sql);}测试文件:require"file_a.php";require"file_b.php";require_once"PHPUnit/Framework/TestCase.php";classtestProblemStatistic

php - Laravel Eloquent 模型查询 `not null`

我一直在为一个项目使用Laravel,并使用Eloquent模型来获取我需要的模型实例。但是,看起来没有办法查询notnull值。https://laravel.com/docs/5.4/eloquent#retrieving-models有没有办法做这样的事情,我想获得所有ticket_id为notnull的Flight模型?$flight=App\Flight::where('ticket_id','!=',null); 最佳答案 试试这个$flight=App\Flight::whereNotNull('ticket_id')

php - "Cannot use string offset as an array"错误

不知道这里出了什么问题。阅读人们在这里说的话:http://informationideas.com/news/2006/06/14/fatal-error-cannot-use-string-offset-as-an-array-in/在这里:Cannotusestringoffsetasanarrayinphp我在$entries(来自Google日历)中print_r()编辑了实际值,它们都很好。foreach($entriesas$e){$info=array();//addedtoseeifpre-declarationhelps$info=array($e['title']

php - 哪个更快 - bool 变量检查或 is_null()?

假设我正在创建一个session类,相关实现如下:publicclassSession(){private$id;private$user;}如果session已登录,$user字段包含一个User类型的对象,如果session未登录到站点,则该字段为null。$id是sessionID。假设我现在想知道用户是否已登录。显然我可以检查$user是否为空,如果是则用户未登录-如下所示:publicclassSession(){private$id;private$user;publicfunctionisLoggedIn(){return!is_null($user);}}或者,我可以存

php - 错误 :- php is not recognised as an internal or external command

关闭。这个问题是off-topic.它目前不接受答案。想改进这个问题吗?Updatethequestion所以它是on-topic用于堆栈溢出。关闭9年前。Improvethisquestion所以这是我的路径:C:\wamp\bin\php\php5.4.3我的php.exe文件在该文件夹中...我试着把:C:\wamp\bin\php\php5.4.3;C:\wamp\bin\php\php5.4.3\php.exeC:\wamp\bin\phpC:\wamp\bin\php;但没有一个是行不通的。我不知道为什么它不起作用......谢谢