Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\Inetpub\wwwroot\webroot\www.novotempo.org.br\lib\Twitter.php on line 54

Hi, I´m Douglas from Brazil, and this above is my problem.

The line is just a DEFINE.... this one : define('DEBUG',false);

Searching the net I found that this usually occurs when you´re using PHP 4.xx, but I´m using 5.2.6 (Just saw it using phpinfo())

I tryed locally, and in two other external hosts, but it keeps returning the same msg.

Anyone can help? Tanx!

Doug

share|improve this question
The true problem is probably one one of the lines before it – Greg Aug 17 '09 at 16:05
Can you post more of the code (a few lines above and a few beneath)? – Miky Dinescu Aug 17 '09 at 16:06

2 Answers

If you are trying to DEFINE something inside of a class but outside of a function, you are going to get this error.

(Normally the only place PHP will be looking for a function and not expecting a string is in a class, outside of a method)

IE: Your code should not look like this:

class myClass
{
    define("DEBUG", true);
    function myFunc()
     {
     }
}
share|improve this answer

Thanks for this, resolved an annoying issue quite quickly for me.

I'd also like to add that the use of hyphens in constant names doesn't work and is apparently expected behaviour. It seems as though the echo tries to evaluate mathematics (minus) on the words.

<?php
define('THIS-IS-A-TEST','Testing');
echo THIS-IS-A-TEST;
?>

Returns '0'

<?php
define('THIS_IS_A_TEST','Testing');
echo THIS_IS_A_TEST;
?>

Returns 'Testing'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.