Welcome Guest, Not a member yet? Register   Sign In
safe null string
#1

[eluser]jared4444[/eluser]
I am trying to print out a form that uses a object. If an item is not defined, I want to display an empty string.

I keep getting errors when I try to call this function.
Message: Trying to get property of non-object


print Inputhelper::nulltostring($myobect->name);


class Inputhelper {

public static function nulltostring($input)
{
//if(isnull($input)) neither work
if(isset($input))
return "";
else
return $input;
}
}
#2

[eluser]John_Betong[/eluser]
[quote author="jared4444" date="1258878353"]I am trying to print out a form that uses a object. If an item is not defined, I want to display an empty string.
...
...
...
}[/quote]
 
Here try this, it works for all sorts of variables:
 
http://ellislab.com/forums/viewthread/130302/#653952
 
 
 




Theme © iAndrew 2016 - Forum software by © MyBB