1

I get an error on my class

[31-Dec-2016 20:05:53 Africa/Casablanca] PHP Parse error: syntax error, unexpected 'Private' (T_PRIVATE), expecting identifier (T_STRING) in /home/address/main.php on line 5

Haven't added anything to the class yet

    <?php

  class Modeladdonmain extends Hand {

      public function Private() {

      }

      public function Poke() {

      }

      public function Whisper() {

      }

  }
 ?>
Martin
  • 22,212
  • 11
  • 70
  • 132
MAH3R
  • 27
  • 6
  • Why was this question upvoted? – Martin Dec 31 '16 at 20:22
  • @Martin I upvoted this because when I saw this code I was stunned it contained an error and wanted to test it out myself to see if I get the same error. Basically, because of how interesting it was to me. – Gynteniuxas Dec 31 '16 at 20:35
  • @EdvinTenovimas ok, but the reason as to why this error occurs is explained *in the error quoted by the OP*. It could be an interesting topic in general, but I don't think this question shows much worth `:-/` – Martin Dec 31 '16 at 20:38
  • @Martin I know that the reason is explained in the error but still, it looked quite strange to me. :) Speaking of effort, [some question](http://stackoverflow.com/questions/179123/how-to-modify-existing-unpushed-commits) are highly upvoted when content is minimal, so I think it's ok if I upvote one or two questions like this one. :) – Gynteniuxas Dec 31 '16 at 20:47
  • @EdvinTenovimas hahaha -yeah you make good point- but just because it's common doesn't make it *Right* `;-)`. I'm not intending to have a go at you at all and respect both that you told me the reasons why and the reason itself. It was just on my first impression of the question I didn't see why it warrented a +1. – Martin Dec 31 '16 at 20:51

1 Answers1

3

Your function Private() contains special word private which is used for declaring members, etc.

Any other similar name would solve your issue. For example, instead of Private() you can use something like privateFunction() (if you're ok with that name).

Similarly, you can't use names like Protected() or Public().

Gynteniuxas
  • 7,035
  • 18
  • 38
  • 54