Jump to content

"IF" control not working as expected...


lopes_andre

Recommended Posts

Hi,

 

How can I get this control working?

 

function get_photo_thumb($type, $folder, $file){
	if ($type <> ('detalhe' || 'zona') ) {
		return 0; // do notnhing.
	}
	else {	

	switch ($type) {
	    case "detalhe":
	        $width	= '200';
		$height = '150';
	        break;
	    case "zona":
	        $width	= '400';
		$height = '300';
	        break;
	    case "zonadestaque":
	        $width	= '500';
		$height = '400';
	        break;
	}

..... ...... .....
}

 

If I pass the parameter $type as 'zonadestaque' the control does not return 0.

 

What can I do to get this working?

 

 

Best Regards,

Link to comment
https://forums.phpfreaks.com/topic/186454-if-control-not-working-as-expected/
Share on other sites

This line is not right

if ($type <> ('detalhe' || 'zona') ) {

You cannot compare multiple values at once. The above should be written as

if ($type != 'detalhe' || $type != 'zona' ) {

 

What are you trying to achieve with the function?

 

Weird, if I do this, works

 

if ($type != 'detalhe' && $type != 'zona' )

 

The function get the thumb of a picture, the parameter TYPE gives me the size of the image. What I need to control is the string TYPE, if is not "detalhe" or "zona", do nothing.

 

Best Regards,

 

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.