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;
<?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?

1 Attachment

 
Gondwana replied on at Permalink Reply
Gondwana
Are you using php's echo() or print() to emit the HTML?

Or are you doing it outside of php's tags? Eg: ...?> <p>this is html</p><?php ...
clint15 replied on at Permalink Reply
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.
<?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="...">


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.
Gondwana replied on at Permalink Reply
Gondwana
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.
clint15 replied on at Permalink Reply
I actually need to have a block where the content is supposed to go but this doesn't work either.
<?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.
Gondwana replied on at Permalink Reply
Gondwana
http://php.net/manual/en/tutorial.php