unexpected T_VARIABLE, expecting T_FUNCTION
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
add a comment |
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
add a comment |
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
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
php magento-2.1
edited 13 mins ago
Teja Bhagavan Kollepara
3,01241949
3,01241949
asked Dec 29 '16 at 1:46
nierunieru
1314
1314
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You should add a space after "const":
const STATUS_PENDING = 'pending';
const STATUS_APPROVED = 'approved';
const STATUS_DECLINED = 'declined';
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
add a comment |
<?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
Maybe you should move this to another question so this thread is clean
– Stijn Duynslaeger - Echron
Dec 29 '16 at 2:37
add a comment |
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();
I already figured out my error Thank you so much!
– nieru
Dec 29 '16 at 2:43
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You should add a space after "const":
const STATUS_PENDING = 'pending';
const STATUS_APPROVED = 'approved';
const STATUS_DECLINED = 'declined';
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
add a comment |
You should add a space after "const":
const STATUS_PENDING = 'pending';
const STATUS_APPROVED = 'approved';
const STATUS_DECLINED = 'declined';
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
add a comment |
You should add a space after "const":
const STATUS_PENDING = 'pending';
const STATUS_APPROVED = 'approved';
const STATUS_DECLINED = 'declined';
You should add a space after "const":
const STATUS_PENDING = 'pending';
const STATUS_APPROVED = 'approved';
const STATUS_DECLINED = 'declined';
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
add a comment |
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
add a comment |
<?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
Maybe you should move this to another question so this thread is clean
– Stijn Duynslaeger - Echron
Dec 29 '16 at 2:37
add a comment |
<?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
Maybe you should move this to another question so this thread is clean
– Stijn Duynslaeger - Echron
Dec 29 '16 at 2:37
add a comment |
<?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
<?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
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
add a comment |
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
add a comment |
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();
I already figured out my error Thank you so much!
– nieru
Dec 29 '16 at 2:43
add a comment |
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();
I already figured out my error Thank you so much!
– nieru
Dec 29 '16 at 2:43
add a comment |
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();
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();
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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