PHP variable shortcut? -


is there shorter way this? in header, have this:

$white1 = '/~jonathan/www/index.php'; $white2 = '/'; echo ($_server['request_uri']);  

and here how processing it:

<?php  if ( (($_server['request_uri']) == $white1)  or  (($_server['request_uri']) == $white2) )  echo 'custom-class';  ?> 

i'd have $white3 , $white4 allow ?lang=en

when there handful of options want match against, use in_array this,

$options = array(   '/',   '/~jonathan/www/index.php', ); if(in_array($_server['request_uri'], $options)) {   echo 'custom-class' } 

this method makes easy add list of $options without changing payload or adding more single entry needed. keep array sorted make entries easy find , keep clean.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -