Jump to content

Class.core


NLT

Recommended Posts

Okay, how would I go around doing a core when on another page I want something like so it can lookup the whole table, so if I wanted online_users I could use something like this:

$core-> new Core();
echo $server_status['online_users'];

And if I wanted something like server_name I could use something like

$core-> new Core();
echo $server_status['server_name'];

Link to comment
https://forums.phpfreaks.com/topic/244135-classcore/
Share on other sites

class Core
{
    public function server_status($what)
        $what = mysql_real_escape_string($what);
        mysql_query("SELECT " . $what . " FROM server_status") // * being value
    }
}

 

Or are you just after how to access an object like an array?

 

class Core implements ArrayAccess
{
    public function offsetGet($offset) {
        switch ($offset) {
            case 'server_status':
                return $this->getServerStatus();
        }
    }
    
    public function offsetSet($offset, $value) {/*dummy*/}
    
    public function offsetExists($offset) {
        return in_array($offset, array('server_status', ..));
    }
    
    public function offsetUnset($offset) {/*dummy*/}
}

 

$core = new Core();
print $core['server_status'];

Link to comment
https://forums.phpfreaks.com/topic/244135-classcore/#findComment-1253856
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.