This forum is now read-only. Please use our new forums at

922 points
Submitted by
Jane Cui
about 4 years ago

Why does this code print out "1" instead of "true"?



class Person {
    public $isAlive = true;
    public $firstname;
    public $lastname;
    public $age;

$teacher = new Person();
$student = new Person();

echo $teacher->isAlive;


4 votes


in all the programming languages True = 1 , False =0 (based on the Binary)
so if you print true it's gonna output ->1

112 points
Submitted by
Mohamed Algendy
about 4 years ago

3 votes


in PHP the boolean true is represented by 1 and false by space. Cheers

365 points
Submitted by
Tobias Páez
almost 4 years ago

1 Comment

219ab7f772efb1cd5440659fe629340a?s=140&d=retro David Hollowood over 3 years ago

Thank you. I don't recall seeing that anywhere in the instructions though I might have missed it. I was guessing this was the case but it's nice to have it confirmed.