-4

For a assignment I need to make a public property on a class.

So I did this :

<?php

class MessageController extends Controller
{
    public $defaultAction  =  "hello" ;

    var $theTime = date ( "D M j G:i:s T Y");

    public function actionHello()
    {
            this->render('hello');

    }

but now I see a blank screen.

What did I do wrong ?

Roelof

Edit 1: I use the Yii platform.

Edit 2: Where can I find info how I can make this class property the right way ?

  • where is render function and u r missing $ sign i think $this – HADI Sep 03 '14 at 20:20
  • is this your full code? then it's no wonder you don't see anything. you did not construct your class in the visible code. – low_rents Sep 03 '14 at 20:20
  • You should give information about the MVC framework you're using... – Ben Sep 03 '14 at 20:21
  • debug yourself first? http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851 – Nanne Sep 03 '14 at 20:21

1 Answers1

2

You have multiple issues.

var $theTime = date ( "D M j G:i:s T Y");

var is obsolete which is ironic since you used public on the line before it. You should not copy and paste code from other sources.

Also, you cannot call functions when declaring a member variable. You have to set this in your constructor or in a method.

this->render('hello');

You're missing your $ for $this: $this->render('hello');

You also forgot the closing } for your class definition.

Lastly, you need to turn on error reporting so all errors are displayed. PHP wanted to tell you about those errors. Let it.

Community
  • 1
  • 1
John Conde
  • 217,595
  • 99
  • 455
  • 496