Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - If something is the case, do nothing

Tags:

php

logic

Is this a proper way to say: if something is the case, do nothing?

if ( ($hostNameInfo == $hostNameInput) && ($hostAddressInfo == $hostAddressInput) )
{
  return;
}

Update: I'm not inside a function. :( So the return is just nonsense.

Here is more code:

//if the input fields are equal to database values, no need to update and waste resources,hence, do nothing:
if ( ($hostNameInfo == $hostNameInput) && ($hostAddressInfo == $hostAddressInput) )
{
  //do nothing
}
//If, however, (they are NOT equal and) input fields are not empty:
elseif (!empty($hostNameInput) && (!empty($hostAddressInput)))
{
 //do something.
}

Thanks in advance, MEM

like image 490
MEM Avatar asked Sep 03 '10 09:09

MEM


1 Answers

For do nothing you simply can type:

function relax() {
    ;
}

if (($hostNameInfo == $hostNameInput) && ($hostAddressInfo == $hostAddressInput)) {
    relax();
}
like image 187
Roberto Avatar answered Sep 28 '22 02:09

Roberto