nctfleetlist Posted January 25, 2011 Share Posted January 25, 2011 I am using simple machines forum, and by placing a link to ssi.php in the top of my php page <?php require_once('/forum/SSI.php');?> I am able to use some ssi functions. My problem is calling another function from within a function. My first function is this: <?php $allowed_groups = array(1,5); $can_see = FALSE; foreach ($allowed_groups as $allowed) if (in_array($allowed, $user_info['groups'])) { $can_see = TRUE; break; } if ($can_see) { echo ' <div> this is text that i want certain groups to see </div>'; } else { //message or section to show if they are not allowed. echo 'this is text that i dont want certain groups to see'; } ?> This is my second function: <?php ssi_welcome(); ?> I want to put the second function inside the first function, like so: if ($can_see) { echo ' <div> <?php ssi_welcome(); ?> </div>'; this just gives me the "<?php ssi_welcome(); ?>" displayed on the actual site, it is not calling the separate function. I have tried different approaches, e.g. $function ssi_welcome; but all it does is display this as text as well.. Please can some one point me in the right direction. Thank you Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 25, 2011 Share Posted January 25, 2011 the first code you posted is not a function. a function starts like this: function someFunctionName() { // Function contents } Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 25, 2011 Share Posted January 25, 2011 but perhaps the solution is as simple as this? echo '<div>' . ssi_welcome() . '</div>'; Quote Link to comment Share on other sites More sharing options...
nctfleetlist Posted January 25, 2011 Author Share Posted January 25, 2011 thanks for your quick reply, I am still learning php so got confused with what is and what is not a function lol. doing what you suggested I either get " Parse error: syntax error, unexpected '>' in [full path to my file name] If I use a backslash (\) to quit the apostrophe's (') it simply prints the text as is: (' . ssi_welcome() . ' '; ) Quote Link to comment Share on other sites More sharing options...
Mr Hyde Posted January 25, 2011 Share Posted January 25, 2011 What kind of output are you expecting from ssi_welcome()? Does it print something to the screen? Does it return a variable? Do you know? Quote Link to comment Share on other sites More sharing options...
nctfleetlist Posted January 25, 2011 Author Share Posted January 25, 2011 As far as I am aware it prints something to the screen. In normal circumstances <?php ssi_welcome(); ?> displays as "Wecome Guest" or if user is logged in "welcome member_name" Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 25, 2011 Share Posted January 25, 2011 can you post the updated code and the line number referenced in the parse error? Quote Link to comment Share on other sites More sharing options...
nctfleetlist Posted January 25, 2011 Author Share Posted January 25, 2011 Parse error: syntax error, unexpected '>' in /home/nctflee1/public_html/account/test.php on line 24 <?php $allowed_groups = array(1,5); $can_see = FALSE; foreach ($allowed_groups as $allowed) if (in_array($allowed, $user_info['groups'])) { $can_see = TRUE; break; } if ($can_see) { echo ' <div> <font class="font">'<div>' . ssi_welcome() . '</div>'; </div></font> </div>'; } else { //message or section to show if they are not allowed. echo ''; } ?> thanks for your help so far Quote Link to comment Share on other sites More sharing options...
Mr Hyde Posted January 25, 2011 Share Posted January 25, 2011 <?php $allowed_groups = array(1,5); $can_see = FALSE; foreach ($allowed_groups as $allowed) if (in_array($allowed, $user_info['groups'])) { $can_see = TRUE; break; } if ($can_see) { echo ' <div> <font class="font"><div>' . ssi_welcome() . '</div> </div></font> </div>'; } else { //message or section to show if they are not allowed. echo ''; } ?> That should work... Quote Link to comment Share on other sites More sharing options...
nctfleetlist Posted January 25, 2011 Author Share Posted January 25, 2011 It worked a treat!! Thank you ever so much for your time and help Mr Hyde, it is most appreciated!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.