Forum Moderators: coopster

Message Too Old, No Replies

Calling classes and functions

How to call a class and functions in it?

         

kkonline

10:31 am on Aug 19, 2007 (gmt 0)

10+ Year Member



I have a variable as
$subject=$_POST['subject'] then how do i call a class (so all functions are executed within it) and how to call individual function of the class. I want to pass $_POST['subject'] to the class / function

The name of the class is

class popoon_classes_externalinput

and it contains two functions

static function basicClean($string) and static function removeMagicQuotes($data)

dreamcatcher

10:59 am on Aug 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$subject = $_POST['subject'];

$class = new popoon_classes_externalinput();
$subject = $class->basicClean($subject);
$subject = $class->removeMagicQuotes($subject);

echo $subject;

You might also want to read up on classes before attempting to use them:
[php.net...]

dc

Habtom

11:04 am on Aug 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Static Methods

$subject = $_POST['subject'];

popoon_classes_externalinput::basicClean($subject)

Assuming you want to pass, $subject to basicClean function.

Hab

Habtom

11:08 am on Aug 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dreamcatcher, I didn't see your post.

Aren't those static functions? Am I missing something here?

WesleyC

2:43 pm on Aug 19, 2007 (gmt 0)

10+ Year Member



Yes they are--and assuming this is PHP5 (as it must be to use the static keyword without throwing a parser error) the method should indeed be called using class_name::method_name(args).