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 Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/ 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? Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/#findComment-1410523 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. Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/#findComment-1410553 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? Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/#findComment-1410556 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. Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/#findComment-1410712 Share on other sites More sharing options...
Christian F. Posted February 7, 2013 Share Posted February 7, 2013 Nope, it produces a syntax error for an unexpected {. Easily testable by yourself, btw, by running one line via the PHP CLI shell. Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/#findComment-1410746 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. Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/#findComment-1410751 Share on other sites More sharing options...
Love2c0de Posted February 7, 2013 Share Posted February 7, 2013 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. Link to comment https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/#findComment-1410796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.