Using a view with some parameters

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I try to develop an application with a controller (which acts as the
model also, meaning it performs calls to db and all this) and a view.

For example, there's a controller called professor which will act upon
members of the site (teachers, professors) who will login.

In my class professor  I have a function:
function login() {
         $loginForm=new professorLoginForm("professors/login");
         if($this->_post) {
         } else {


Since I 'm not posting the form now the $loginForm->ShowLogin(); is

professorLoginForm is an extension of LoginForm where I have a function:

function ShowLogin($loginErrors="") {
         if($this->use_cookies) {

         if($loginErrors!="") $loginvars['errors']=$loginErrors;


         return $logform;

and another function

function get_include_contents($filename) {
     if (is_file($filename)) {
         include( $filename);
         $contents = ob_get_contents();
         return $contents;
     return false;

The problem is in the views/generalLoginForm.php. The beginning of it has:
<?php global  $loginvars,$loginclassname;?>
<form class="<?php echo $loginclassname; ?>" action="<?php echo
$loginvars['action']; ?>"

$loginvars and $loginclassname is always "". Why is that?

The reason for using the get_include_contents instead of just including
it is because in my controller I have a function:

function Display() {
         print $this->todisplay;

I know this may be a wrong approach and I would like to comment on it if

Thanks and sorry for the huge post.


Re: Using a view with some parameters

On Jun 12, 11:37 am, Harris Kosmidhs
Quoted text here. Click to load it
Quoted text here. Click to load it

Because they are not in the global scope.


Re: Using a view with some parameters

Harris Kosmidhs wrote:
Quoted text here. Click to load it

Just like I said - if they need to change a value, they use references
or return a value.  They don't do anything any different.

The php manual has a lot of good stuff on both passing by reference and
returning values from functions.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline