How to make [group=][/group]?

In general, I am making a script and I need to do it in order to

  • for guest [group=0] | [/group],
  • for user [group=1][/group].

If done as a conditional statement:

if($_SESSION['session_id'] = '') {echo '';} else {echo '';}

then it’s inconvenient… Here you need to do as I said above (I couldn’t cut it with DLE). All scripts in sessions. (This is not a DLE, but a self-written one.)

Answer 1, authority 100%

This can be done in javascript, unfortunately I don’t have the code, but it’s roughly done like this:

In JS we do:

function checkUL() {
 var elem = document.getElementById('touser');
  ( ) { 
  elem.innerHTML = '[group=0] | [/group]';
 } else {
  elem.innerHTML = '[group=1][/group]';
<body onload="checkUL">
<label id="touser"></label>

Add the tags yourself.

Answer 2, authority 100%

I’ve always been in favor of reducing the load and speeding up work, so I suggested using JS.
How do you like this option?

function logginedOrNot() {
    switch (empty($_SESSION['session_id'])) :
        case true :
            $answ   =   'no';
        case flase :
            $answ   =   'yes';

Answer 3, authority 100%

$tpl['group0'] = '[group=0]...[/group]';
$tpl['group1'] = '[group=1]...[/group]';
if($_SESSION['session_id'] = '') {
    echo $tpl['group0'];
} else {
    echo $tpl['group1'];

IMHO, storing template parts in variables is more convenient, since they are all located in one place in the code.