unexpected T_VARIABLE, expecting T_FUNCTION












2















I am following a tutorial from a book named Magento cookbook. But even though I followed all the codes, I keep on getting this error.




Parse error: syntax error, unexpected 'constSTATUS_PENDING'
(T_STRING), expecting function (T_FUNCTION) in
C:xampphtdocsmagentoappcodePacktHelloWorldModelSubscription.php
on line 7




namespace PacktHelloWorldModel;
class Subscription extends MagentoFrameworkModelAbstractModel
{

constSTATUS_PENDING = 'pending';
constSTATUS_APPROVED = 'approved';
constSTATUS_DECLINED = 'declined';

public function __construct(
MagentoFrameworkModelContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkModelResourceModelAbstractResource $resource = null,
MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
array $data = )
{

parent::__construct($context,$registry, $resource, $resourceCollection, $data);
}

public function _construct()
{
$this->_init('PacktHelloWorldModelResourceModelSubscription');
}
}









share|improve this question





























    2















    I am following a tutorial from a book named Magento cookbook. But even though I followed all the codes, I keep on getting this error.




    Parse error: syntax error, unexpected 'constSTATUS_PENDING'
    (T_STRING), expecting function (T_FUNCTION) in
    C:xampphtdocsmagentoappcodePacktHelloWorldModelSubscription.php
    on line 7




    namespace PacktHelloWorldModel;
    class Subscription extends MagentoFrameworkModelAbstractModel
    {

    constSTATUS_PENDING = 'pending';
    constSTATUS_APPROVED = 'approved';
    constSTATUS_DECLINED = 'declined';

    public function __construct(
    MagentoFrameworkModelContext $context,
    MagentoFrameworkRegistry $registry,
    MagentoFrameworkModelResourceModelAbstractResource $resource = null,
    MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
    array $data = )
    {

    parent::__construct($context,$registry, $resource, $resourceCollection, $data);
    }

    public function _construct()
    {
    $this->_init('PacktHelloWorldModelResourceModelSubscription');
    }
    }









    share|improve this question



























      2












      2








      2








      I am following a tutorial from a book named Magento cookbook. But even though I followed all the codes, I keep on getting this error.




      Parse error: syntax error, unexpected 'constSTATUS_PENDING'
      (T_STRING), expecting function (T_FUNCTION) in
      C:xampphtdocsmagentoappcodePacktHelloWorldModelSubscription.php
      on line 7




      namespace PacktHelloWorldModel;
      class Subscription extends MagentoFrameworkModelAbstractModel
      {

      constSTATUS_PENDING = 'pending';
      constSTATUS_APPROVED = 'approved';
      constSTATUS_DECLINED = 'declined';

      public function __construct(
      MagentoFrameworkModelContext $context,
      MagentoFrameworkRegistry $registry,
      MagentoFrameworkModelResourceModelAbstractResource $resource = null,
      MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
      array $data = )
      {

      parent::__construct($context,$registry, $resource, $resourceCollection, $data);
      }

      public function _construct()
      {
      $this->_init('PacktHelloWorldModelResourceModelSubscription');
      }
      }









      share|improve this question
















      I am following a tutorial from a book named Magento cookbook. But even though I followed all the codes, I keep on getting this error.




      Parse error: syntax error, unexpected 'constSTATUS_PENDING'
      (T_STRING), expecting function (T_FUNCTION) in
      C:xampphtdocsmagentoappcodePacktHelloWorldModelSubscription.php
      on line 7




      namespace PacktHelloWorldModel;
      class Subscription extends MagentoFrameworkModelAbstractModel
      {

      constSTATUS_PENDING = 'pending';
      constSTATUS_APPROVED = 'approved';
      constSTATUS_DECLINED = 'declined';

      public function __construct(
      MagentoFrameworkModelContext $context,
      MagentoFrameworkRegistry $registry,
      MagentoFrameworkModelResourceModelAbstractResource $resource = null,
      MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
      array $data = )
      {

      parent::__construct($context,$registry, $resource, $resourceCollection, $data);
      }

      public function _construct()
      {
      $this->_init('PacktHelloWorldModelResourceModelSubscription');
      }
      }






      php magento-2.1






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 13 mins ago









      Teja Bhagavan Kollepara

      3,01241949




      3,01241949










      asked Dec 29 '16 at 1:46









      nierunieru

      1314




      1314






















          3 Answers
          3






          active

          oldest

          votes


















          1














          You should add a space after "const":



          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';





          share|improve this answer
























          • the error is now gone but i got another

            – nieru
            Dec 29 '16 at 2:15











          • What error do you get now?

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:16











          • Fatal error: Class PacktHelloWorldModelResourceModelSubscription contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkModelResourceModelAbstractResource::_construct) in C:xampphtdocsmagentoappcodePacktHelloWorldModelResourceModelSubscription.php on line 12

            – nieru
            Dec 29 '16 at 2:16











          • Can you post your current code cause it doesn't show an abstract function above. You should also make the function _construct() protected like in the class you are extending

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:23











          • I posted it on answers

            – nieru
            Dec 29 '16 at 2:26



















          0














          <?php

          namespace PacktHelloWorldModel;

          class Subscription extends MagentoFrameworkModelAbstractModel{


          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';

          public function __construct(

          MagentoFrameworkModelContext $context,
          MagentoFrameworkRegistry $registry,
          MagentoFrameworkModelResourceModelAbstractResource $resource = null,
          MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
          array $data = )
          {
          parent::__construct($context,$registry, $resource, $resourceCollection, $data);
          }

          public function _construct()
          {
          $this->_init('PacktHelloWorldModelResourceModelSubscription');
          }
          }


          this is my current code






          share|improve this answer


























          • Maybe you should move this to another question so this thread is clean

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:37



















          0














          The problem is not in your Model but in your ResoureModel class "PacktHelloWorldModelResourceModelSubscription". You should implement 2 abstract methods from the "MagentoFrameworkModelResourceModelAbstractResource" class:



          abstract protected function _construct();
          abstract protected function getConnection();





          share|improve this answer
























          • I already figured out my error Thank you so much!

            – nieru
            Dec 29 '16 at 2:43












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f152265%2funexpected-t-variable-expecting-t-function%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You should add a space after "const":



          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';





          share|improve this answer
























          • the error is now gone but i got another

            – nieru
            Dec 29 '16 at 2:15











          • What error do you get now?

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:16











          • Fatal error: Class PacktHelloWorldModelResourceModelSubscription contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkModelResourceModelAbstractResource::_construct) in C:xampphtdocsmagentoappcodePacktHelloWorldModelResourceModelSubscription.php on line 12

            – nieru
            Dec 29 '16 at 2:16











          • Can you post your current code cause it doesn't show an abstract function above. You should also make the function _construct() protected like in the class you are extending

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:23











          • I posted it on answers

            – nieru
            Dec 29 '16 at 2:26
















          1














          You should add a space after "const":



          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';





          share|improve this answer
























          • the error is now gone but i got another

            – nieru
            Dec 29 '16 at 2:15











          • What error do you get now?

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:16











          • Fatal error: Class PacktHelloWorldModelResourceModelSubscription contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkModelResourceModelAbstractResource::_construct) in C:xampphtdocsmagentoappcodePacktHelloWorldModelResourceModelSubscription.php on line 12

            – nieru
            Dec 29 '16 at 2:16











          • Can you post your current code cause it doesn't show an abstract function above. You should also make the function _construct() protected like in the class you are extending

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:23











          • I posted it on answers

            – nieru
            Dec 29 '16 at 2:26














          1












          1








          1







          You should add a space after "const":



          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';





          share|improve this answer













          You should add a space after "const":



          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 29 '16 at 1:53









          Stijn Duynslaeger - EchronStijn Duynslaeger - Echron

          461312




          461312













          • the error is now gone but i got another

            – nieru
            Dec 29 '16 at 2:15











          • What error do you get now?

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:16











          • Fatal error: Class PacktHelloWorldModelResourceModelSubscription contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkModelResourceModelAbstractResource::_construct) in C:xampphtdocsmagentoappcodePacktHelloWorldModelResourceModelSubscription.php on line 12

            – nieru
            Dec 29 '16 at 2:16











          • Can you post your current code cause it doesn't show an abstract function above. You should also make the function _construct() protected like in the class you are extending

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:23











          • I posted it on answers

            – nieru
            Dec 29 '16 at 2:26



















          • the error is now gone but i got another

            – nieru
            Dec 29 '16 at 2:15











          • What error do you get now?

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:16











          • Fatal error: Class PacktHelloWorldModelResourceModelSubscription contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkModelResourceModelAbstractResource::_construct) in C:xampphtdocsmagentoappcodePacktHelloWorldModelResourceModelSubscription.php on line 12

            – nieru
            Dec 29 '16 at 2:16











          • Can you post your current code cause it doesn't show an abstract function above. You should also make the function _construct() protected like in the class you are extending

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:23











          • I posted it on answers

            – nieru
            Dec 29 '16 at 2:26

















          the error is now gone but i got another

          – nieru
          Dec 29 '16 at 2:15





          the error is now gone but i got another

          – nieru
          Dec 29 '16 at 2:15













          What error do you get now?

          – Stijn Duynslaeger - Echron
          Dec 29 '16 at 2:16





          What error do you get now?

          – Stijn Duynslaeger - Echron
          Dec 29 '16 at 2:16













          Fatal error: Class PacktHelloWorldModelResourceModelSubscription contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkModelResourceModelAbstractResource::_construct) in C:xampphtdocsmagentoappcodePacktHelloWorldModelResourceModelSubscription.php on line 12

          – nieru
          Dec 29 '16 at 2:16





          Fatal error: Class PacktHelloWorldModelResourceModelSubscription contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkModelResourceModelAbstractResource::_construct) in C:xampphtdocsmagentoappcodePacktHelloWorldModelResourceModelSubscription.php on line 12

          – nieru
          Dec 29 '16 at 2:16













          Can you post your current code cause it doesn't show an abstract function above. You should also make the function _construct() protected like in the class you are extending

          – Stijn Duynslaeger - Echron
          Dec 29 '16 at 2:23





          Can you post your current code cause it doesn't show an abstract function above. You should also make the function _construct() protected like in the class you are extending

          – Stijn Duynslaeger - Echron
          Dec 29 '16 at 2:23













          I posted it on answers

          – nieru
          Dec 29 '16 at 2:26





          I posted it on answers

          – nieru
          Dec 29 '16 at 2:26













          0














          <?php

          namespace PacktHelloWorldModel;

          class Subscription extends MagentoFrameworkModelAbstractModel{


          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';

          public function __construct(

          MagentoFrameworkModelContext $context,
          MagentoFrameworkRegistry $registry,
          MagentoFrameworkModelResourceModelAbstractResource $resource = null,
          MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
          array $data = )
          {
          parent::__construct($context,$registry, $resource, $resourceCollection, $data);
          }

          public function _construct()
          {
          $this->_init('PacktHelloWorldModelResourceModelSubscription');
          }
          }


          this is my current code






          share|improve this answer


























          • Maybe you should move this to another question so this thread is clean

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:37
















          0














          <?php

          namespace PacktHelloWorldModel;

          class Subscription extends MagentoFrameworkModelAbstractModel{


          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';

          public function __construct(

          MagentoFrameworkModelContext $context,
          MagentoFrameworkRegistry $registry,
          MagentoFrameworkModelResourceModelAbstractResource $resource = null,
          MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
          array $data = )
          {
          parent::__construct($context,$registry, $resource, $resourceCollection, $data);
          }

          public function _construct()
          {
          $this->_init('PacktHelloWorldModelResourceModelSubscription');
          }
          }


          this is my current code






          share|improve this answer


























          • Maybe you should move this to another question so this thread is clean

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:37














          0












          0








          0







          <?php

          namespace PacktHelloWorldModel;

          class Subscription extends MagentoFrameworkModelAbstractModel{


          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';

          public function __construct(

          MagentoFrameworkModelContext $context,
          MagentoFrameworkRegistry $registry,
          MagentoFrameworkModelResourceModelAbstractResource $resource = null,
          MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
          array $data = )
          {
          parent::__construct($context,$registry, $resource, $resourceCollection, $data);
          }

          public function _construct()
          {
          $this->_init('PacktHelloWorldModelResourceModelSubscription');
          }
          }


          this is my current code






          share|improve this answer















          <?php

          namespace PacktHelloWorldModel;

          class Subscription extends MagentoFrameworkModelAbstractModel{


          const STATUS_PENDING = 'pending';
          const STATUS_APPROVED = 'approved';
          const STATUS_DECLINED = 'declined';

          public function __construct(

          MagentoFrameworkModelContext $context,
          MagentoFrameworkRegistry $registry,
          MagentoFrameworkModelResourceModelAbstractResource $resource = null,
          MagentoFrameworkDataCollectionAbstractDb $resourceCollection = null,
          array $data = )
          {
          parent::__construct($context,$registry, $resource, $resourceCollection, $data);
          }

          public function _construct()
          {
          $this->_init('PacktHelloWorldModelResourceModelSubscription');
          }
          }


          this is my current code







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 29 '16 at 2:33









          Stijn Duynslaeger - Echron

          461312




          461312










          answered Dec 29 '16 at 2:25









          nierunieru

          1314




          1314













          • Maybe you should move this to another question so this thread is clean

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:37



















          • Maybe you should move this to another question so this thread is clean

            – Stijn Duynslaeger - Echron
            Dec 29 '16 at 2:37

















          Maybe you should move this to another question so this thread is clean

          – Stijn Duynslaeger - Echron
          Dec 29 '16 at 2:37





          Maybe you should move this to another question so this thread is clean

          – Stijn Duynslaeger - Echron
          Dec 29 '16 at 2:37











          0














          The problem is not in your Model but in your ResoureModel class "PacktHelloWorldModelResourceModelSubscription". You should implement 2 abstract methods from the "MagentoFrameworkModelResourceModelAbstractResource" class:



          abstract protected function _construct();
          abstract protected function getConnection();





          share|improve this answer
























          • I already figured out my error Thank you so much!

            – nieru
            Dec 29 '16 at 2:43
















          0














          The problem is not in your Model but in your ResoureModel class "PacktHelloWorldModelResourceModelSubscription". You should implement 2 abstract methods from the "MagentoFrameworkModelResourceModelAbstractResource" class:



          abstract protected function _construct();
          abstract protected function getConnection();





          share|improve this answer
























          • I already figured out my error Thank you so much!

            – nieru
            Dec 29 '16 at 2:43














          0












          0








          0







          The problem is not in your Model but in your ResoureModel class "PacktHelloWorldModelResourceModelSubscription". You should implement 2 abstract methods from the "MagentoFrameworkModelResourceModelAbstractResource" class:



          abstract protected function _construct();
          abstract protected function getConnection();





          share|improve this answer













          The problem is not in your Model but in your ResoureModel class "PacktHelloWorldModelResourceModelSubscription". You should implement 2 abstract methods from the "MagentoFrameworkModelResourceModelAbstractResource" class:



          abstract protected function _construct();
          abstract protected function getConnection();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 29 '16 at 2:34









          Stijn Duynslaeger - EchronStijn Duynslaeger - Echron

          461312




          461312













          • I already figured out my error Thank you so much!

            – nieru
            Dec 29 '16 at 2:43



















          • I already figured out my error Thank you so much!

            – nieru
            Dec 29 '16 at 2:43

















          I already figured out my error Thank you so much!

          – nieru
          Dec 29 '16 at 2:43





          I already figured out my error Thank you so much!

          – nieru
          Dec 29 '16 at 2:43


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f152265%2funexpected-t-variable-expecting-t-function%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Berlina muro

          Last logged in always never, not logging

          Berlina aerponto