/    Sign up×
Community /Pin to ProfileBookmark

Simple PHP error doing my head in

Why am I getting this error? I’m following a tutorial.

Parse error: syntax error, unexpected ‘int’ (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in C:wamp64wwwproduct.php on line 5

“`
<?php
class Product {

private int $id;
private string $title;
private float $price;
private int $availableQuantity;
“`

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@kiwisauthorOct 01.2020 — PHP 7.4 required.
Copy linkTweet thisAlerts:
@Trish14Oct 01.2020 — @kiwis80#1623818

Hello,

Trust you're keeping good.

Surely, we can assist you on your requirements.

Please Reach me on my Email- Trish[@]cisinlabs[dot]com

Regards,

Trish
Copy linkTweet thisAlerts:
@NachfolgerOct 01.2020 — Omit the type declarations.
Copy linkTweet thisAlerts:
@kiwisauthorOct 01.2020 — @Nachfolger#1623831 I've done that, is that a PHP version 7.4 thing?
Copy linkTweet thisAlerts:
@NogDogOct 02.2020 — > @kiwis80#1623838 is that a PHP version 7.4 thing?

Yep: https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.typed-properties
Copy linkTweet thisAlerts:
@VITSUSAOct 03.2020 — @kiwis80#1623818 I agree with NogDog, PHP 7.4 will required.
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...