Jump to content

Boolean Checking Type Against True


quasiman

Recommended Posts

Sorry about the topic title, I'm not really sure how else to simply explain this...

 

Anyway, can someone explain why this doesn't work? I'm checking the type with '===' versus checking value with '=='. I could just use the two ==, but I want to know why...

 

<?php
function validate($value, $type) {
switch ($type) {
 case "url":
	 if (filter_var($value, FILTER_VALIDATE_URL) === TRUE)
		 return TRUE;
	 break;
 default:
	 return FALSE;
}
}

if (validate('http://gmail.com','url')) {
echo 'true';
} else {
echo 'false';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/271936-boolean-checking-type-against-true/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.