eldan88 Posted April 27, 2013 Share Posted April 27, 2013 Hey, I have a question. I am trying to echo out constant using the ternary operator, but its not echoing. Below is one line of code I am using. Any suggestions? echo defined(STORE_ADDRESS) ? STORE_ADDRESS : "" Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 27, 2013 Share Posted April 27, 2013 And the problem is? Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 27, 2013 Author Share Posted April 27, 2013 And the problem is? The constant is not being echoed. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 27, 2013 Share Posted April 27, 2013 What debugging have you done? It's fairly obvious that either the constant is defined with a blank value, or it's not defined. The code appears fine, and it sounds like its working. Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 27, 2013 Author Share Posted April 27, 2013 What debugging have you done? It's fairly obvious that either the constant is defined with a blank value, or it's not defined. The code appears fine, and it sounds like its working. Im sorry. I was using the right code for the wrong reason. What I was trying to accomplish is echoing out a constant only if it has been defined using the ternary operator. Is there a way where I can accomplish this? Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 27, 2013 Share Posted April 27, 2013 That is what you're doing. Quote Link to comment Share on other sites More sharing options...
Solution akphidelt2007 Posted April 27, 2013 Solution Share Posted April 27, 2013 You need quotes around STORE_ADDRESS other wise it is using the STORE_ADDRESS constant value to check whether it is defined. So it should be defined('STORE_ADDRESS') Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 28, 2013 Author Share Posted April 28, 2013 You need quotes around STORE_ADDRESS other wise it is using the STORE_ADDRESS constant value to check whether it is defined. So it should be defined('STORE_ADDRESS') That worked. Thanks a lot for your help! Quote Link to comment 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.