Jump to content

Function Calling


nctfleetlist

Recommended Posts

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

 

Link to comment
Share on other sites

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() . '

'; )

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.