Solved

how to call a class properly

Posted on 2012-03-26
3
190 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 110

Accepted Solution

by:
Ray Paseur earned 500 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

690 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