php classses
Posted: Sun May 10, 2009 9:15 am
how to pass a value to variable inside a class?
i need pass username which was eccepted from a user to the variable $pass inside the class test. this is the code i've tried so far
can anybody help me with this please
i need pass username which was eccepted from a user to the variable $pass inside the class test. this is the code i've tried so far
Code: Select all
<?php
class Example {
/////////////////////variables//////////////
var $user ;
var $pass ;
////////////setters & getters //////////////////
function set_user($usr)
{
$this-> user= $usr;
}
function get_user()
{
return $this-> user;
}
function set_pass($pas)
{
$this-> pass= $pas;
}
function get_pass()
{
return $this-> pass;
}
/////////////////////////////////////////////////
function foo() {
echo "foo!\n";
}
}
// create an Example object
$e = new Example();
echo $e->get_user();
echo $e->foo();
echo $e->get_pass();
?>