# Parsing/syntax error

**URL:** <https://www.phphelp.com/t/parsing-syntax-error/35581>\
**Category:** Beginners - Learning PHP\
**Created:** [July 31, 2023, 9:13am UTC](https://www.phphelp.com/t/parsing-syntax-error/35581 "2023-07-31T09:13:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeCalo](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/f08c70/32.png) [@MikeCalo](https://www.phphelp.com/u/MikeCalo)\
**Post date:** [July 31, 2023, 9:13am UTC](https://www.phphelp.com/t/parsing-syntax-error/35581/1 "2023-07-31T09:13:13Z")

</div>

I am getting a parsing/syntax error on the 4th line of the following script; it says “unexpected identifier “function\_construct”, expecting 'function” or “const”…  
class Paint\_1  
{  
private string $color ;  
function\_construct ( string $hue=‘Blue’ )  
{  
$this-\>color=$hue ;  
}  
public function SETCOLOR (string $c)  
{  
$this-\>color=$c ;  
}  
public function GETCOLOR()  
{  
return $this-\>color ;  
}  
}

---

<div class="post-metadata">

**Author:** ![Strider64](https://www.phphelp.com/user_avatar/www.phphelp.com/strider64/32/3161_2.png) [@Strider64](https://www.phphelp.com/u/Strider64)\
**Post date:** [July 31, 2023, 11:46am UTC](https://www.phphelp.com/t/parsing-syntax-error/35581/2 "2023-07-31T11:46:40Z")

</div>

> [@MikeCalo](#):
>
> class Paint\_1  
> {  
> private string $color ;  
> function\_construct ( string $hue=‘Blue’ )  
> {  
> $this-\>color=$hue ;  
> }  
> public function SETCOLOR (string $c)  
> {  
> $this-\>color=$c ;  
> }  
> public function GETCOLOR()  
> {  
> return $this-\>color ;  
> }  
> }

```auto
class Paint_1
{
    private string $color;

    public function __construct(string $hue='Blue')
    {
        $this->color = $hue;
    }

    public function SETCOLOR(string $c)
    {
        $this->color = $c;
    }

    public function GETCOLOR()
    {
        return $this->color;
    }
}

```

Don’t know what you’re trying to do, but you had the constructor wrong it should be written `__construct` and you had the wrong quotes in `$hue='blue'` I think or it could had just been the way it was copied over.

---

<div class="post-metadata">

**Author:** ![katsry](https://www.phphelp.com/letter_avatar_proxy/v4/letter/k/2bfe46/32.png) [@katsry](https://www.phphelp.com/u/katsry)\
**Post date:** [July 31, 2023, 7:08pm UTC](https://www.phphelp.com/t/parsing-syntax-error/35581/3 "2023-07-31T19:08:41Z")

</div>

Your code `Strider64`, is a perfect solution.
