Jump to content

problem: join 2 strings in a class


abahaedini

Recommended Posts

hi thereI have a constants as name: FIXED_VAR,I defined it in the config.php file! (another file) define("FIXED_VAR", ""pre_); now, I define a class:

class admins extends users{var $table_name=FIXED_VAR."admins";function ...}

but I get an error:

Parse error: syntax error, unexpected '.', expecting ',' or ';' in F:\server\www\samaschools\score\core\classes\admins.php on line 3
in line 3 these code works:var $table_name="admins";var $table_name=FIXED_VAR; but these code dosent work:var $table_name=FIXED_VAR."admins";var $table_name=$_session['type']; what's wrong? is there any solutions?
Link to comment
Share on other sites

You can't operate when declaring a class property. That's what the constructor is for. The constructor is written like this:

function __construct() {    $this->table_name = FIXED_VAR . 'admins';}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...