html - PHP Conditional Tag -
i'm trying change color of svg when current page "work.php"
using following code
<?php if($page=='work'){echo 'white';} else{echo '#c22533';}?>
i consistently color '#c22533' if on "work.php"
how might correct php code?
try this:
<?php echo (stripos($_server['php_self'], 'work.php')) ? 'white' : '#c22533'; ?>
or, using $page
variable:
<?php $page = 'work'; echo (stripos($_server['php_self'], $page.'.php')) ? 'white' : '#c22533'; ?>
Comments
Post a Comment