I am developing a stats site in Codeigniter locally. I have a url like localhost/sitename/player/show_profile/PlayerName
I currently have the following:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Player extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('player_model');
$player_name = $this->uri->segment(3);
}
public function index()
{
echo "index";
}
public function show_profile($player_name)
{
$data['player_stats'] = $this->player_model->get_stats( $player_name );
$this->load->view('player/player_stats', $data);
}
}
?>
This works, but my question is regarding the $player_name variable. I have $player_name = $this->uri->segment(3);
in the __construct so it's available to all of the class methods. Is this the way I should be doing it?
Is this safe?