mbodamer Posted February 6, 2013 Share Posted February 6, 2013 Hi, I am trying tomimic this functionality: <?php if($listing['bedrooms']) : ?><b>Bedrooms:</b> <?php echo $listing['bedrooms'] ?><br/> <?php endif; ?> that is on a working site but I do not have the variable defined yet. I have a program that generates tags like this: {bedrooms} so I am seeking to match IF bedrooms=3 (for example) then display 3bed.jpg this is what I was trying but it failed miserably: <?php $name = {name}; if($name == "joe") : ?><img src="joe.jpg"><?php endif; ?> hopefully you can follow my wayward logic. Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 6, 2013 Share Posted February 6, 2013 {name} is not valid PHP. What are you trying to set $name to? Quote Link to comment Share on other sites More sharing options...
mbodamer Posted February 6, 2013 Author Share Posted February 6, 2013 Well like I said... {name} is a tag that is generated from a program that I can simply put on the HMTL page anywhere and it will print the value of {name}. So I need a way to see what that value is, and then if it matches what I want, print something if not ignore it. if I just put {name} on the page it will print "joe" for example. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 6, 2013 Share Posted February 6, 2013 That's doesn't make it valid PHP. What "puts" joe into {name}? What program are you using? Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted February 7, 2013 Share Posted February 7, 2013 Wouldn't PHP interpret {name} as a constant? Regards, L2c. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted February 7, 2013 Share Posted February 7, 2013 (edited) Nope, it produces a syntax error for an unexpected {. Easily testable by yourself, btw, by running one line via the PHP CLI shell. Edited February 7, 2013 by Christian F. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2013 Share Posted February 7, 2013 Good job answering the important questions. Good luck. Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted February 7, 2013 Share Posted February 7, 2013 (edited) Nope, it produces a syntax error for an unexpected {. Easily testable by yourself, btw, by running one line via the PHP CLI shell. Wow I was never aware we could run php from the command line. I was at work when I replied to that, usually I would just test something before asking a question etc. So eunning PHP from the command line means we don't need a local server for example to run PHP scripts? I'm going to give the php.net a thorough read regarding CLI when I get back. I might do a bit of PHP in my break now, they already got n++ installed Kind regards, L2c. Edited February 7, 2013 by Love2c0de 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.