CodeIgniter Forums
NULL check problem/question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: NULL check problem/question (/showthread.php?tid=13970)



NULL check problem/question - El Forum - 12-13-2008

[eluser]Unknown[/eluser]
Hi,

I have a question, I'm probably missing something obvious, but wanted to ask for help:

I have this line of code in my controller:

Code:
$data['category'] = null;

I am passing this into my view like follows:

Code:
$this->load->view('catalogue_view', $data);

In my view file (catalogue_view.php), I have the following line:

Code:
<?php if (is_null($category)): ?>

My problem is, my if statement is evaluating to false, even though I know it has been set to false.

What am I missing here?

Thanks,
C.


NULL check problem/question - El Forum - 12-14-2008

[eluser]thinkigniter[/eluser]
Try
Code:
<?php (is_null($category))? echo 'nothing here' : echo $category  ; ?>