0

I am trying a simple code igniter hello world tutorial but keep getting this error and don't know why.

Parse error: syntax error, unexpected T_CLASS in C:\xampp\htdocs\loxxbylisa\application\controllers\helloworld.php on line 3

<? php

    class HelloWorld extend CI_Controller {

    public function index(){
            $this->load->view('helloworld');
        }

    }

?>

I am running it in XAMPP and my helloworld.php in views folder is just the text "hello world". Any suggestions?

3 Answers 3

2

The only thing that jumps out at me right now is you have a space between your opening

class HelloWorld extends CI_Controller

Notice the "s" at the end of extend. Should be extends. http://php.net/manual/en/keyword.extends.php

Sign up to request clarification or add additional context in comments.

Comments

1

Please use this code it will work for you.. In controller ...you have use wrong spelling of extend...it should be extends

<?php

    class HelloWorld extends CI_Controller {

        public function index(){
            $this->load->view('helloworld');
        }

    }

?>

Create a view in the views with the name helloworld.php

2 Comments

Yes I have fixed that but the problem still remains.
the problem was the space after php.
0

I had a similar error while working with Codeignitor:

An uncaught Exception was encountered
Type: ParseError
Message: syntax error, unexpected 'class' (T_CLASS)

My code was as follows:

defined('BASEPATH') OR exit('No direct script access allowed')

class Migrate extends CI_Controller

The problem here is that I should have ended the first line with a ;

Unexpected T_CLASS can therefore be the result of several typos. Always check your code!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.