?
Solved

how to call a class properly

Posted on 2012-03-26
3
Medium Priority
?
191 Views
Last Modified: 2012-04-13
How would i call the following class??

<?php
class vBulletinUser{
	public static function login($username, $remember_me = false){
		chdir(VB_ROOT_PATH);
		require_once('./global.php');
		require_once(DIR . '/includes/functions_login.php');
		global $vbulletin,$vbphrase;
		$remember_me = $remember_me ? true : false;	//force to true or false value
		$vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 
			username, password, salt FROM ".TABLE_PREFIX."user WHERE username = '".
			$vbulletin->db->escape_string(htmlspecialchars_uni($username))."'");
			
		if ($vbulletin->userinfo){
			process_new_login($vbulletin->GPC['logintype'], $remember_me, $vbulletin->GPC['cssprefs']);
			exec_shut_down();
			return true;
		}
		return false;
	}
}

new vBulletinUser();
?>

Open in new window

0
Comment
Question by:runnerjp2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 37768684
I don't think I would call it.  It looks like a PHP4 implementation, maybe.  No class constructor, etc.  But that aside...

$x = new VBulletinUser();
if ($x->login('UserName', TRUE)) echo "WE GOT LOGGED IN";
0
 
LVL 7

Expert Comment

by:designatedinitializer
ID: 37789850
It's not PHP4 because it's 'static', and there weren't static methods back then.
You call it like this:
VBulletinUser::login('UserName', TRUE);

Open in new window

0
 
LVL 7

Expert Comment

by:designatedinitializer
ID: 37844571
seems like there are different meanings to the word "properly"...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question