Click to See Complete Forum and Search --> : php5 : Testing for null string
KiwiDexter
Jun 5th, 2010, 02:30 AM
What is the php equiv of the following test for a null string value
$value = somefuntion($A, $B)
if not($value) then
* string is empty do processing
else
* string has a value rock on dude
end
TIA and go Fiji this evening ....
kows
Jun 5th, 2010, 03:34 AM
are you testing for a null value, or an empty string?
if(empty($value)){
// this value is an empty string -- ""
}else{
// this value is not an empty string
}
if(is_null($value)){
// this value == null
}else{
// this value != null
}
if($value === ""){
// $value is exactly equal to an empty string ("")
}else{
// $value is not an empty string
}
if($value === null){
// $value is exactly equal to null
}else{
// $value is not null
}
you should be alright using empty() to test for an empty string and is_null() to test for a null value.
KiwiDexter
Jun 5th, 2010, 08:28 PM
Think empty() looks like what I'm after. Will test him out this morning and see how I go :wave:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.