JamesKoash Posted August 26, 2013 Share Posted August 26, 2013 Hi there all, Slowly getting back into PHP after a long hiatus from any coding. Here is a quick piece of code that I put together, to display a logo depending on whether a variable is true or false, but it doesn't seem to be working. if ( $showlogo = TRUE ) { $logo = "<img src=\"logo.png\" \>"; } elseif ( $showlogo = FALSE ) { $logo = ""; } echo $logo; This code is located in is called template.php. Each page on the website, so for example index.php, calls this template using the include function and those pages are where the variable $showlogo are set. Could anyone advise me on why it may not be working? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/281574-php-not-checking-if-statement-for-variable/ Share on other sites More sharing options...
Solution taquitosensei Posted August 26, 2013 Solution Share Posted August 26, 2013 you need to use == otherwise you're changing the value to TRUE if($showlog ==True) even better use if($showlogo) That checks for true/false Hi there all, Slowly getting back into PHP after a long hiatus from any coding. Here is a quick piece of code that I put together, to display a logo depending on whether a variable is true or false, but it doesn't seem to be working. if ( $showlogo = TRUE ) { $logo = "<img src=\"logo.png\" \>"; } elseif ( $showlogo = FALSE ) { $logo = ""; } echo $logo; This code is located in is called template.php. Each page on the website, so for example index.php, calls this template using the include function and those pages are where the variable $showlogo are set. Could anyone advise me on why it may not be working? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/281574-php-not-checking-if-statement-for-variable/#findComment-1446864 Share on other sites More sharing options...
JamesKoash Posted August 26, 2013 Author Share Posted August 26, 2013 That's great, thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/281574-php-not-checking-if-statement-for-variable/#findComment-1446866 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.