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
Share on other sites

No. I mean I need the core.php file (code) for that.

 

So something like:

class Core
{
    {     function server_status()
           mysql_query("SELECT * FROM server_status") // * being value
     }
}

 

Link to comment
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
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.