mercredi 22 avril 2015

How to use public function return string for variable in same class? PHP Class

I am trying to use a returned string from my function 'get_setting' inside my class name 'settings'. I wanna use the returned string for the variable 'top_banner'. When I try using the '$this' variable to access the function, it does not work.

class settings{

 function get_setting($name, $return="value"){
    $query = mysql_query("SELECT * FROM website_settings WHERE name='".$name."'");
    $row = mysql_fetch_array($query);
    if($row['active'] == false){//This is turned off
        return "disabled";
    }else{//this setting is active
        return $row['value'];

public $top_banner = $this->get_settings("top_banner");

Aucun commentaire:

Enregistrer un commentaire