If statement errors
Permalink
Hi, I'm trying to show different content to users depending on the group the user belongs to, so I have this if statement;
The problem is I can't seem to be able to add tags (<>) where the content is supposed to go. If I do, I get a php error "Parse error: syntax error, unexpected '<' ". What could I be missing or have done wrong?
<?php $u = new User(); $g = Group::getByName('Store Customer'); if ($u->inGroup($g)) { //content 1 here } $g = Group::getByName('Guest'); if ($u->inGroup($g)) { //content 2 here } ?>
The problem is I can't seem to be able to add tags (<>) where the content is supposed to go. If I do, I get a php error "Parse error: syntax error, unexpected '<' ". What could I be missing or have done wrong?
I'm doing it inside the php tags. For instance if I want to use an editable area or even an image, I get that error.
I saw on another thread instead of tags, someone using
But that didn't work for me, it brings up no errors but the section stays blank.
<?php ... $g = Group::getByName('Store Customer'); if ($u->inGroup($g)) { //content_1 <?php $a = new Area('example_block'); $a->display($c); ?> //content_1 } $g = Group::getByName('Guest'); if ($u->inGroup($g)) { //content_2 <img src="...">
Viewing 15 lines of 20 lines. View entire code block.
I saw on another thread instead of tags, someone using
$code = "/path/to/image.jpeg";
But that didn't work for me, it brings up no errors but the section stays blank.
php and html are different languages. You can't include html directly inside php tags like that. Look at the example code I posted before; the html is not between corresponding php start and end tags.
I actually need to have a block where the content is supposed to go but this doesn't work either.
So, how do I go about adding a block without the php tags, <?php giving me an error message? Or to put it simply, anything I add beginning with a tag < generates an error.
<?php $a = new Area('example_block'); $a->display($c); ?>
So, how do I go about adding a block without the php tags, <?php giving me an error message? Or to put it simply, anything I add beginning with a tag < generates an error.
http://php.net/manual/en/tutorial.php
Or are you doing it outside of php's tags? Eg: ...?> <p>this is html</p><?php ...