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

922 points
Submitted by
Jane Cui
over 4 years ago

[resolved] 4/10 Why does isAlive print "1" instead of true?

Property Panic (1)

This code works, but why does it pop up "1" and not "true on the screen?


    class Person{

        public $isAlive = true;
        public $firstname = "Jane";
        public $lastname = "Cui";
        public $age = 24;


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

    echo $teacher->isAlive;


5 votes


Hi Jane, I have wondered this myself but never bothered to track down the answer - until now - so thanks for asking.

In the php docs there is a section about strings and it says this: "A boolean TRUE value is converted to the string "1". Boolean FALSE is converted to "" (the empty string). This allows conversion back and forth between boolean and string values."

Digging a bit deeper I found that you can use var_dump (manual page) to print the type and value of a variable. So:

echo var_dump($teacher->isAlive);

will give you: bool(true)

3698 points
Submitted by
over 4 years ago


52983e67abf821c6b5005d7f_23743677 Jane Cui over 4 years ago

ok thanks.

55df2afa95e3787b9200005e_359368177 Judy over 4 years ago

You're welcome.