Jump to content

Echo function inside string?


piznac

Recommended Posts

Hey guys,.. there has got to be a way to do this or a work around. Example:

 

<?php
function home(){
$con = '<span class="main-text">Well well well,.. it would seem you have found   your way to the brotherhood of {WRL}. More then a simple gaming clan, we are   what you would call a movement. Honor, respect & duty,.. these are words we   take seriously. Honor your clan, respect to all, & and your duty to your   clan.<br />
                <br />
                Here rank matters very little, and although we do strive to be the   best we can be. Your loyality to our cause is of the greatest importance. You   will come to find that we are not the typical gaming clan. We do not promote for   skills or even consider it that important. We do not attack other clans of   players with any evil intent. Although we do plan and host many wars, these are   for fun or competition only.<br />
                <br />
                Also we support many games and are constanly   expanding. Our forums are very active and our site recieves over 1 million hits   a month. So welcome to the brotherhood,.. follow the rules, treat people with   respect and reserve your spot in history with the {WRL} movement. 
                Make sure that you read the rules section and   such</span><br />
                <br />
                <br /><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="2%" class="head_repeat"><img src="images/mid-left-head.gif" width="9" height="25" /></td>
                  <td width="96%" class="head_repeat style7">Recent Post</td>
                  <td width="2%" class="head_repeat"><div align="right"><img src="images/mid-right-head.gif" width="9" height="25" /></div></td>
                </tr>
                <tr>
                  <td height="13" colspan="3" bgcolor="#CECFCE" class="menu-bor">' . ssi_recentTopics() . '</td>
                </tr>
              </table>
              <br />
              <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="2%" class="head_repeat"><img src="images/mid-left-head.gif" width="9" height="25" /></td>
                  <td width="96%" class="head_repeat style7">Gaming News </td>
                  <td width="2%" class="head_repeat"><div align="right"><img src="images/mid-right-head.gif" width="9" height="25" /></div></td>
                </tr>
                <tr>
                  <td colspan="3" bgcolor="#CECFCE" class="menu-bor"><br />' . include ("rss.php") . '<br /></td>
                </tr>
              </table>';
		  

}
?>

 

This displays the function "ssi_recentTopics() " no matter what happens. Is there way to hold this data inside the string so I can call it where I need it?

Link to comment
Share on other sites

Can't you just rewrite the ssi_recentTopics() function so that it doesn't echo data, but returns a string?

 

If thats not possible, then you might be able to use output buffering. You'll need to place ob_start() at the top of your script. You'll then need to flush the contents of the buffer (what has been output to the screen), before calling the ssi_recentTopics() function (this enables any other output to be unaffected), call the ssi_recentTopics() function, then use ob_get_clean() to get the new contents of the buffer (what is echoed in ssi_recentTopics() ) , and place it inside your string.

 

<?php
ob_start();//placed at the TOP of your script
//the rest of your script
function home(){
	ob_flush();//flush current contents of buffer - any other content would be sent now.
	ssi_recentTopics();//call the function
$con = '<span class="main-text">Well well well,.. it would seem you have found   your way to the brotherhood of {WRL}. More then a simple gaming clan, we are   what you would call a movement. Honor, respect & duty,.. these are words we   take seriously. Honor your clan, respect to all, & and your duty to your   clan.<br />
                <br />
                Here rank matters very little, and although we do strive to be the   best we can be. Your loyality to our cause is of the greatest importance. You   will come to find that we are not the typical gaming clan. We do not promote for   skills or even consider it that important. We do not attack other clans of   players with any evil intent. Although we do plan and host many wars, these are   for fun or competition only.<br />
                <br />
                Also we support many games and are constanly   expanding. Our forums are very active and our site recieves over 1 million hits   a month. So welcome to the brotherhood,.. follow the rules, treat people with   respect and reserve your spot in history with the {WRL} movement. 
                Make sure that you read the rules section and   such</span><br />
                <br />
                <br /><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="2%" class="head_repeat"><img src="images/mid-left-head.gif" width="9" height="25" /></td>
                  <td width="96%" class="head_repeat style7">Recent Post</td>
                  <td width="2%" class="head_repeat"><div align="right"><img src="images/mid-right-head.gif" width="9" height="25" /></div></td>
                </tr>
                <tr>
                  <td height="13" colspan="3" bgcolor="#CECFCE" class="menu-bor">' . ob_get_clean() . '</td>
                </tr>
              </table>
              <br />
              <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="2%" class="head_repeat"><img src="images/mid-left-head.gif" width="9" height="25" /></td>
                  <td width="96%" class="head_repeat style7">Gaming News </td>
                  <td width="2%" class="head_repeat"><div align="right"><img src="images/mid-right-head.gif" width="9" height="25" /></div></td>
                </tr>
                <tr>
                  <td colspan="3" bgcolor="#CECFCE" class="menu-bor"><br />' . include ("rss.php") . '<br /></td>
                </tr>
              </table>';
		  

}
?>

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.