Page 1 of 1

Classes named Session

Posted: Thu Jan 12, 2006 3:35 pm
by Charles256
does that cause issues in PHP5?because my class called session is suddenly displaying all it's code on the webpage when I upgraded to version 5 :-/

Posted: Thu Jan 12, 2006 4:15 pm
by Chris Corbyn
It souldn't matter. The superglobals are in a different namespace to classes (in PHP5 classes share the namespace with interfaces and that's it AFAIK). Are you sure PHP5 isn't having other issues?

Posted: Fri Jan 13, 2006 8:07 am
by BDKR
Is it only that class or all of your code?

Posted: Fri Jan 13, 2006 8:10 am
by Jenk
have you tried changing the name just to test?

Posted: Tue Jan 17, 2006 1:30 pm
by Charles256
thanks for the replies and sorry for the long delay. i only work at this job two days a week so it's been a while since I've had access to the source code. Either way...going back we find..
time = time(); $this->startSession(); } /* *
that's the beginning of the output on the page and that goes all the way till the code ends..i will now show relevant code up till that point..

Code: Select all

*
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 19, 2004
 */
include("database.php");
include("mailer.php");
include("form.php");

class Session
{
   var $username;     //Username given on sign-up
   var $userid;       //Random value generated on current login
   var $userlevel;    //The level to which the user pertains
   var $time;         //Time user was last active (page loaded)
   var $logged_in;    //True if user is logged in, false otherwise
   var $userinfo = array();  //The array holding all user info
   var $url;          //The page url current being viewed
   var $referrer;     //Last recorded site page viewed
   /**
    * Note: referrer should really only be considered the actual
    * page referrer in process.php, any other time it may be
    * inaccurate.
    */

   /* Class constructor */
   function Session(){
      $this->time=time();
      $this->startSession();
as you can see up until it gets to $this->time it's fine..something about that arrow is <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> it off though....Any more ideas? I've renamed the class..no dice...

Posted: Tue Jan 17, 2006 2:21 pm
by Jenk
assuming you have missed it when copying, but just to be on the safe side, the page does start with /* and not just * right?

Posted: Tue Jan 17, 2006 3:40 pm
by Charles256
I just missed it when copying :-D And I removed all comments before the troubled section..still same error.just spitting the code to the page...I FIGURED IT OUT! mwua ha ha...I noted he was using short tags..so I thought to myself....do I have short tags enabled? no sir I do not. therefore I replaced all short tags with long tags and tada. Heh... Man I feel like an idiot..

Posted: Tue Jan 17, 2006 5:50 pm
by raghavan20
d11wtq, do you say if an user defined class is named session, it will not be a problem even if there already exists a class with name session used by PHP?

How the distinction is made? I just want to know how are you guys handling namespaces in PHP. I do not think even PHP 5 does have that feature. If I want to create two different classes with the same name, how can I do that if I am not able to use packages which I think is not available in PHP 5.

Posted: Tue Jan 17, 2006 6:44 pm
by Ambush Commander
Namespaces are not available in PHP 5. Supposedly (and the same goes for Unicode), PHP6 will make all our troubles vanish.

Other than that, you just have to be careful when you name classes common names.