Jump to content

CodeIgniter Tutorials


in2tech

Recommended Posts

I am trying to learn the basic's of CodeIgniter and keep having pretty much the same error on any of the tutorials. I have tried the Static Pages and the News tutorial and I a getting the same error? I can't figure it out, and I don't understand what the user on the CodeIgniter forums is referring too as the error and how to fix it :) Hoping someone here can help me out.

Here is the link to the Static Pages Tutorial:

https://www.codeigniter.com/user_guide/tutorial/static_pages.html

This is the main error in the controller Pages.php file:

An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected 'public' (T_PUBLIC), expecting end of file

Filename: /Applications/MAMP/htdocs/CI/application/controllers/Pages.php

Line Number: 12

Backtrace:

File: /Applications/MAMP/htdocs/CI/index.php
Line: 315
Function: require_once

 

And this is the code it is referring too:

public function view($page = 'home')

And here is the entire controller Pages.php code:

<?php
class Pages extends CI_Controller {

        public function view($page = 'home')
        {
        }
}

 


public function view($page = 'home')
{
        if ( ! file_exists(APPPATH.'views/pages/'.$page.'.php'))
        {
                // Whoops, we don't have a page for that!
                show_404();
        }

        $data['title'] = ucfirst($page); // Capitalize the first letter

        $this->load->view('templates/header', $data);
        $this->load->view('pages/'.$page, $data);
        $this->load->view('templates/footer', $data);
}

Any help is much appreciated!

 

Updated #1 - I think I figured it out...I think...I'll get back to you!

Updated #2 - I got it working...yeah. I'm actually glad I figured it out myself!

Edited by jnascar
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...