PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 23rd, 2013, 06:05 PM
we5inelgr we5inelgr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 99 we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 59 m 39 sec
Reputation Power: 1
Question Php Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNC

Hi all,

Getting this error while trying to create a constant inside an object:

Quote:
php Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'


The line it's complaining about is this, which is inside a class:

PHP Code:
const SI_IMAGE_JPEG 1


b.t.w. I'm running PHP version 5.2.17.

Why would I be getting this error?

Reply With Quote
  #2  
Old February 23rd, 2013, 06:37 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,696 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 4 h 30 m 39 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
What's the rest of the code?

Reply With Quote
  #3  
Old February 23rd, 2013, 06:59 PM
we5inelgr we5inelgr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 99 we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 59 m 39 sec
Reputation Power: 1
the object is being called from another file:

PHP Code:
include_once ('securimage.php');
$secureimage = new Securimage(); 

The file is there, named exactly that.

The Securimage() object, in the securimage.php is:

PHP Code:
class Securimage
{
    
// All of the public variables below are securimage options
    // They can be passed as an array to the Securimage constructor, set below,
    // or set from securimage_show.php and securimage_play.php

    /**
     * Renders captcha as a JPEG image
     * @var int
     */
    
const SI_IMAGE_JPEG 1; <----
    
/**
     * Renders captcha as a PNG image (default)
     * @var int
     */
    
const SI_IMAGE_PNG  2

and continues.

The line with the arrow is the line the error is occuring on according to php.

Reply With Quote
  #4  
Old February 23rd, 2013, 08:19 PM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,804 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 17 h 28 m 32 sec
Reputation Power: 6112
That code works for me. Are you sure you're in the right file?
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #5  
Old February 24th, 2013, 12:34 AM
we5inelgr we5inelgr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 99 we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 59 m 39 sec
Reputation Power: 1
Quote:
Originally Posted by ManiacDan
That code works for me. Are you sure you're in the right file?


Yeah, because if I comment out that line, then the error occurs on the next constant:

PHP Code:
const SI_IMAGE_PNG  2

Reply With Quote
  #6  
Old February 24th, 2013, 12:45 AM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,931 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 7 h 43 m 47 sec
Reputation Power: 7053
You would only receive that error message in this context if you were not actually running PHP 5.

Add:
PHP Code:
die(phpversion()); 

immediately before your require statement and determining what value it outputs. I would be very surprised if it's actually 5.2.17.
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #7  
Old February 24th, 2013, 01:07 AM
we5inelgr we5inelgr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 99 we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 59 m 39 sec
Reputation Power: 1
Quote:
Originally Posted by E-Oreo
You would only receive that error message in this context if you were not actually running PHP 5.

Add:
PHP Code:
die(phpversion()); 

immediately before your require statement and determining what value it outputs. I would be very surprised if it's actually 5.2.17.


Well isn't that interesting.

When using (at the top of the page):

PHP Code:
echo phpinfo(); 

I get PHP version 5.2.17.

And using:
PHP Code:
die(phpversion()); 

I get 4.4.9

Why the difference? Perhaps because I'm on a shared server? How does that work? Some on the server have 5.2.17, and my site doesn't?

It makes sense now why the OO PHP doesn't work if I'm really running 4.4.9 and not 5.2.17. But still, two different answers on the same page?

Reply With Quote
  #8  
Old February 24th, 2013, 06:26 AM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,696 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 4 h 30 m 39 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
There's some difference. Maybe the way the run is running, maybe the file extension, maybe where the file is located... Something is different.

Reply With Quote
  #9  
Old February 25th, 2013, 08:27 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,804 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 17 h 28 m 32 sec
Reputation Power: 6112
Yeah...it might be a good idea to uninstall/reinstall PHP.

Are you really saying that if you put phpinfo() at the top of the page, you get 5+, and if you put phpversion() at the bottom of the page, you get 4? You're accessing the page in the same way?

Last edited by ManiacDan : February 25th, 2013 at 08:39 AM.

Reply With Quote
  #10  
Old February 25th, 2013, 06:40 PM
we5inelgr we5inelgr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 99 we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 59 m 39 sec
Reputation Power: 1
Quote:
Originally Posted by ManiacDan
Yeah...it might be a good idea to uninstall/reinstall PHP.

Are you really saying that if you put phpinfo() at the top of the page, you get 5+, and if you put phpversion() at the bottom of the page, you get 4? You're accessing the page in the same way?


Yeah.

Reply With Quote
  #11  
Old February 25th, 2013, 06:44 PM
we5inelgr we5inelgr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 99 we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level)we5inelgr User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 59 m 39 sec
Reputation Power: 1
I finally figured out what was going on.

If the page calling the OO PHP was a .html page, phpversion() shows 4.4.9.
If the page calling the OO PHP was a .php page, phpversion() shows 5.2.17.

And, either page extension type would show version 5.2.17 with phpinfo();

Even though the page (either the .html or the .php version) were accessed in the same way and they had identical code...only the .php extension page would get phpversion() to show the 5.2.17 version whereas the .html page would give the 4.4.9 version.

Why that's the case, I don't know yet (probably server configuration as to how .html pages are rendered with the php engine), but I got it working now by simply changing the page extension from .html to .php.

The server host company is making changes to allow .html pages to behave the same with this regards.

Last edited by we5inelgr : February 25th, 2013 at 06:49 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Php Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNC

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap