You are here: Session/Class help « PHP Programming Language « IT news, forums, messages
Session/Class help

Posted by Jon on 03/01/06 00:50

All,

I'm currently building a custom Content Management system for a site we're
working on, and am stuck. Currently, I am using a couple of classes to run
most of the queries throughout the application. Well, I'm pretty stuck now.

What I need to do is use a variable throughout my classes that is a Session
variable. I really can't find another solution. The syntax I was using for
this variable before (I actually hard coded it during my testing and
development before this point) was this:

class C_DisplayContent{

var $username = "S_";

function foo(){
//code that uses the variable as $this->username
}//end foo

}//end class

So, what I really need now is to have the variable look like this:

var $username = $_SESSION['username'];

and be able to use it like normal using the $this->username syntax. However,
PHP seems to blow up at it. I've tried numerous ways of doing this
syntactically and I always end up with errors. The current error I'm getting
is:

Parse error: parse error, unexpected T_VARIABLE in

The line is of course the line where I'm assigning the variable.

What am I missing in regards to using session variables within a class? Any
help is appreciated.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация