I have another problem.
Im getting an internal server error when I try to get data from the following php class:
<?php
/**
* Created by JetBrains PhpStorm.
* User: -Ryuk-
* Date: 21/11/12
* Time: 17:08
* To change this template use File | Settings | File Templates.
*/
class game
{
private $_serverStatus = "Online";
private $_numOnline = "32";
private $_maxPlayers = "50";
private $_messageOfTheDay = "Welcome to game!";
private $_Players = "Falcubar2011;Zacardor;";
public function GetStatus()
{
return this::$_serverStatus;
}
public function GetNumOnline()
{
return this::$_numOnline;
}
public function MaxPlayers()
{
return this::$_maxPlayers;
}
public function GetMOTD()
{
return this::$_messageOfTheDay;
}
public function GetPlayers()
{
return this::$_Players;
}
public function GetServiceColour()
{
if(this::GetStatus() != "Online")
return "#FF0000";
else
return "#008000";
}
}
Im trying to call it like this(in index.php) I stripped this down so you don’t get all the junk.
$mc = new game();
<div id="Stats">
<div id=roundedbox>
<h1>Info</h1>
<p>
<p><strong>IP:</strong> play.game.com</p>
<br>
<p>Slots: <?php print $mc->GetNumOnline(); ?> / <?php print $mc->MaxPlayers(); ?></p>
<br>
<p>Status: <?php print $mc->GetStatus(); ?></p>
<br>
<p>MOTD: <?php print $mc->GetMOTD(); ?></p>
</div>
</div>
Anyone know how to fix this problem im having?
Your syntax around
thisis completely wrong. Instead ofYou should be using
Similarly, your internal call to
GetStatus()should beI recommend you start reading here – http://php.net/manual/en/language.oop5.basic.php