Arman Malekzade Arman Malekzade - 7 months ago 8
PHP Question

Why this php page doesn't work when i add the class?

<?php
echo "1";
class grack_node(){
protected $label;
protected $content;
function __construct($label,$content){
$this->label=$label;
$this->content=$content;
}
function get_label(){return $this->label;}
function get_content(){return $this->content;}
function set_label($label){$this->label=$label;}
function set_content($content){$this->content=$content;}
function set($label,$content){$this->label=$label;$this->content=$content;}
};


So, Here's a very very simple php code that is a part of a larger code. No matter how large is the real project, this 1 part doesn't work. If i remove the class, i see 1 on the browser. But when i add the class, i don't know what goes wrong and why i don't see anything!
What's the problem with my code ?

Note : display_errors is on. also i added the command
error_reporting(E_ALL);
to the first line of my code. Nothing changed!
Thanks in advance.

Answer

Class should be defined without the () brackets

class grack_node{