2

Sample Code:

Config.php:
class Config {
    public $serverIP = "1.1.1.10";
}

DB.php:
require_once "/home/mysite/PHP/Config.php";
class DB extends Config {
    //DB related functions here..
}

research.php:
require_once "/home/mysite/PHP/DB.php";
class research extends DB {
    // Using DB functions to retrieve information from the research tables.
}

On executing the research.php file, I am getting an error message saying:

 "Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/mysite/PHP/research.php on line 1". 

I have checked every possibility that may cause this error. But I couldn't fix it. I have checked few possibilities such as require_once("filepath"); missing braces, etc...

0

4 Answers 4

2

This is on line 1, which you didn't post

Be sure you have space between <?php and first code

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

Comments

1

You might need to specify which parent class for research :-

class research extends <-- where is the parent class?

1 Comment

Sorry for the inconvenience. It was a typing error in my post. I have corrected it. Kindly please check once again and give your thoughts.
0

"Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/mysite/PHP/research.php on line 1"

This means somewhere on line 1 of the /home/mysite/PHP/research.php file, the parser expected a function declaration (T_FUNCTION token) but instead saw a semi-colon (;).

A semi-colon inside of the class definition by itself (for one) will cause this error.

Comments

0

A weird quirk about PHP is it doesn't like semicolons at the end of some blocks but others it is fine with. For instance, a semicolon after a class method gives an error, but after the class definition itself doesn't bother it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.