04-12-2010, 05:07 PM
[eluser]Kanra[/eluser]
Hi, everyone
I haven't played with php for a longtime and now having a little issue hope anyone can help.
Here is part of my code, how can I create $currentYear and $birthdayData so that both my index() & reg_Result() functions can use them?
It keeps saying
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION
Hi, everyone
I haven't played with php for a longtime and now having a little issue hope anyone can help.
Here is part of my code, how can I create $currentYear and $birthdayData so that both my index() & reg_Result() functions can use them?
It keeps saying
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION
Code:
<?php
class Reg extends Controller
{
//problem code
$currentYear = date("Y");
$birthdayData = array("year"=>$currentYear, "i"=>0, "firstThru"=>TRUE);
//problem code
function Reg()
{
//Constructor
parent::Controller();
$this->load->helper(array('form', 'url', 'date'));
$this->load->library(array('form_validation', 'encrypt'));
}
function index()
{
//Load the registration view
$this->load->view('TXTU/regView', $birthdayData);
}
function reg_Result()
{
//set rules for my form validation
$this->set_regform_rules();
if ($this->form_validation->run() == FALSE)
{
$this->load->view('TXTU/regView', $birthdayData);
}
else
{
$this->save_reg_data();
$this->load->view('TXTU/regSuccess');
}
}
?>