View Full Version : function is always called first?

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 = "")

$do = "show_games";
$do = "show_".$_GET['do'];

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

<TABLE WIDTH=\"100%\">
<TD text-align\"left\">
<TD valign=\"top\">Put something Here</TD>

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



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.

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.

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.