
- You are not logged in. | Login
March 19, 2007 2:11 pm
- jjjlc1983
- Member


Unforeseen error appeared when writing Class
I have some troubles with dot in lines 4, 5, 6. I’m told that it shouldn’t be done
class authorization
{
const SESSION_PREFIX = "authorization_";
const SESSION_LOGIN_NAME=self::SESSION_PREFIX."login";
const SESSION_PASSWORD_NAME=self::SESSION_PREFIX."password";
const SESSION_IP_NAME=self::SESSION_PREFIX."ip";
}But I also cannot afford myself writing like this
class authorization
{
const SESSION_LOGIN_NAME="authorization_login";
const SESSION_PASSWORD_NAME="authorization_password";
const SESSION_IP_NAME="authorization_ip";
}What should I do?
March 19, 2007 2:15 pm
- jjjlc1983
- Member


Re: Unforeseen error appeared when writing Class
I’m surprised that PHP Team and Zend SoftWare haven’t foreseen such an action…
March 19, 2007 2:18 pm
- cplusplus
- Member


Re: Unforeseen error appeared when writing Class
jjjlc1983, it isn’t strange. Could you explain me why you need all these troubles with static functions call?
Don’t you know what to do with CPU time and Memory?
March 19, 2007 2:27 pm
- jjjlc1983
- Member


Re: Unforeseen error appeared when writing Class
with static functions call?
Why are you speaking about functions? These are just constants in the Constants class within objects.
Generally speaking, constants are not principal here so you may do like this:
class authorization
{
private $session_prefix="authorization_";
private $session_login_name=$this->session_prefix."login";
private $session_password_name=$this->session_prefix."password";
private $session_ip_name=$this->session_prefix."ip";
//...
}However it doesn’t work either.
March 19, 2007 2:32 pm
- cplusplus
- Member


Re: Unforeseen error appeared when writing Class
I’ve meant function of getting static objects (constants). Sorry for my language but I think you understand me 
March 19, 2007 2:37 pm
- biopd42
- Member


Re: Unforeseen error appeared when writing Class
It isn’t going to work in any language. There are constructors for that.
March 19, 2007 2:40 pm
- sirburpsalot
- Member


Re: Unforeseen error appeared when writing Class
Such is the algorithm of the PHP- compiler. It is fast and simple and meant for execution by each appealing and there is no need in complicating it with logic.
March 19, 2007 2:43 pm
- R@mzess
- Member


Re: Unforeseen error appeared when writing Class
jjjlc1983, this code is implicitly wrong. Where will you get $this i.e. link to an object in the CLASS declaration from? And there is such a notion as static value which is laid by parsing. This means that it can be int/float/string/array but without involving external variables.
March 19, 2007 2:46 pm
- jjjlc1983
- Member


Re: Unforeseen error appeared when writing Class
Thanks. I understood that I was wrong. I’m going to use constructor.



