...

View Full Version : function is always called first?



ptmuldoon
11-27-2007, 02:10 AM
I'm working with a set of php5 scripts, trying to modify it to work with a separate chat script. But for some strange (or not strange) reason, the code for the chat is always loaded first when viewing the page. It even loads before any of the header information.

Would this be something related to php5 in general or something else?

The below function is part of a larger php class


public function show($info = "")
{

if(!isset($_GET['do']))
$do = "show_games";
else
$do = "show_".$_GET['do'];

if($_GET['do'] == "search")
$do = "show_games";

$this->output.="
<TABLE WIDTH=\"100%\">
<TR>
<TD text-align\"left\">
<TABLE>
<TR>
<TD valign=\"top\">Put something Here</TD>
</TR>
<TR>
<TD>".chat_shoutbox()."</TD>
</TR>
</TABLE>
</TD>

<TD valign=\"top\" text-align\"right\">This will be the Right Side blocks</TD>
</TR>
</TABLE>
";

$this->show_output();

}

In the above, I've modified it to include the chat_shoutbox() function. The chat/shoutbox is loaded, but is always the first thing at the top of the page. I've gone as far as making the shoutbox function a simple echo statement, and it still loads first before anything else.

masterofollies
11-27-2007, 02:29 AM
What I believe it is, is your using your ELSE statement too early. Maybe change to ELSEIF and adding ELSE down more. Because it should be like,

>start chat here


>end chat here

(if chat not started)

Do this.

rpgfan3233
11-27-2007, 02:30 AM
When is this function called? If it is called inside a constructor that you use, then the function will be called, and I'm guessing that show_output() will output the string stored in the 'output' member of your class. Without some info about your class and where you create an instance of the class, I can't see any problems.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum