html - Smarty inserts PHP function in <BODY> instead of inside <TD> -


i have simple php function in admin.php

function accountmenu() {     if (isset($_session['user_id']))         { ?>       <a href="update_profile.php">update profile</a><br>       <a href="update_email.php">update e-mail address</a><br>       <a href="logout.php">logout </a>     <?php } } 

i assign variable function in dashboard.php

//smarty paths here  include 'admin.php';  $accountmenu = accountmenu();  $smarty->assign('accountmenu', $accountmenu); $smarty->display('dashboard.tpl'); 

and try display via dashboard.tpl

<body>     <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">         <tr>             <td width="160" valign="top">             {$accountmenu}             </td>             <td width="732" valign="top">                 <h3>dashboard</h3>             </td>         </tr>          <tr>             <td colspan="3">&nbsp;</td>         </tr>     </table> </body> 

what happens accountmenu elements shown after <body> (and before <title>!) , not within <td>.

any idea why happening?

your function doesn't return - outputs html straight buffer, when call this:

$accountmenu = accountmenu(); 

it prints browser , $accountmenu remains null.

change returns desired string, example:

function accountmenu() {     if (isset($_session['user_id'])) return '       <a href="update_profile.php">update profile</a><br>       <a href="update_email.php">update e-mail address</a><br>       <a href="logout.php">logout </a>     '; } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -