+ Reply to Thread
Results 1 to 5 of 5

Thread: const in php doesn't work

  1. #1
    hero080 is offline x10Hosting Member hero080 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    16

    const in php doesn't work

    I have defined a class like:
    PHP Code:
    class MyClass {
      public const 
    AAA 10;  // doesn't work here
      
    public const BBB 100;
      
    // some other methods

    The script halted when it comes to the line of
    Code:
    public const AAA = 10;
    Can anybody give me a clue "why"?

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: const in php doesn't work

    Not 100% sure, but I don't think a const can take a visibility modifier. ie, drop the 'public'
    Nothing is always absolutely so.

  3. #3
    hero080 is offline x10Hosting Member hero080 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    16

    Re: const in php doesn't work

    I don't think so. The visibility should apply to any field/method. And I tried to remove it, it shows the same error.

    A quick quesition. Is x10hosting providing php5 support or earlier version?

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: const in php doesn't work

    Quote Originally Posted by hero080 View Post
    And I tried to remove it, it shows the same error.

    ?
    Same error, but different line number?
    Did you remove both 'public'
    Nothing is always absolutely so.

  5. #5
    hero080 is offline x10Hosting Member hero080 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    16

    Re: const in php doesn't work

    You are a GENIUS!
    Thanks a lot

+ Reply to Thread

Similar Threads

  1. Site DOES work with WWW and DOES NOT work without WWW
    By jasperwm in forum Free Hosting
    Replies: 5
    Last Post: 05-19-2009, 02:21 PM
  2. CGI don't work.
    By filou93 in forum Free Hosting
    Replies: 1
    Last Post: 04-03-2009, 05:07 PM
  3. Website will not work and webdisk will not work
    By omars08 in forum Free Hosting
    Replies: 1
    Last Post: 02-28-2008, 01:06 PM
  4. Ads don't work
    By matol in forum Free Hosting
    Replies: 4
    Last Post: 09-11-2007, 05:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers